RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Make a script that plays a coin sound when the player collects it with instructions"
-- script for the coin part local part = script.Parent local sound = game.Workspace.CoinSound local function collect(otherPart) local player = game.Players:FindFirstChild(otherPart.Parent.Name) if player then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 sound:Play() part:Destroy() end end part.Touched:Connect(collect) -- instructions: 1. Create a part and name it 'CoinPart' 2. Add a sound named 'CoinSound' to the workspace 3. Add this script to the CoinPart 4. When the player touches the CoinPart, it will play the CoinSound and add 1 to the player's Coins value in their leaderstats