Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

how can i make this sound start script only play for the player who touched the brick?

Asked by 2 years ago

hi, i made a script that makes it so when a player touches the brick, it plays a new sound and ends the old one, the only problem is is that it plays the sound for everyone in the server.

here is the script i was using before:

script.Parent.Touched:connect(function(hit)
    game.Workspace.Sound:Play()
end)

here is the script i thought might work:

script.Parent.Touched:connect(function(hit)
    game.Players[hit.Parent.Name].game.Workspace.Sound:Play()
end)

thanks in advance, from poopypigeon245

0
also a localscript didn't work either poopypigeon245 22 — 2y
0
Is the game filtering enabled? WaddelsG 69 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You can use local sounds. You just have to move the sound into the players player gui.

script.Parent.Touched:connect(function(hit)
   local plr = hit.Parent.Name
   if game.Players:FindFirstChild(plr) then
   workspace.Sound:Clone().Parent = game.Players[plr].PlayerGui
   if game.Players[plr].PlayerGui.Sound.IsPlaying == false then
    game.Players[plr].PlayerGui.Sound:Play()
end end end)
0
I would move the sound somewhere in the server storage but it is up to you, killer08932 144 — 2y
0
so it works fine, but i nned to make sure it ends the sound when the next trigger block is touched, i managed to find a way to do it, but it only worked on studio (the part you made worked in game) poopypigeon245 22 — 2y
Ad

Answer this question