hello i been trying to make a thing when u collect a coin you can only hear the sound please help
local db = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if db == true then db = false script.Parent.Transparency = 1 local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5 script.Sound:Play() script.Parent.Transparency = 1 wait (13) db= true script.Parent.Transparency = 0 end end end)
Simple! Use a localscript to play the sound. You can also play it in the PlayerGui or simply move it to ScreenGui and when a server starts it will do it for you. I have rewrotten the script so that the sound will work if it is in the players PlayerGui. Simply drag it in to ScreenGui and let it play.
local db = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if db == true then db = false script.Parent.Transparency = 1 local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5 player:WaitForChild("PlayerGui").Sound:Play() script.Parent.Transparency = 1 wait (13) db= true script.Parent.Transparency = 0 end end end)