Information:
Script:
01 | local finishPart = game.Workspace.Levels.Level 1. Checkpoints:WaitForChild( "Finish" ) |
02 |
03 | function onTouch (hit) |
04 | local H = hit.Parent : FindFirstChild( "Humanoid" ) |
05 | local S = game.Players.LocalPlayer.PlayerGui.Ding |
06 | if H ~ = nil then |
07 | S:Play() |
08 | end |
09 | end |
10 |
11 |
12 | finishPart.Touched:connect(onTouch) |
ok so i have an answer for why it would play for all players, so each player has that script running for them, meaning that when one person touches the part every other script sees that someone touched that part and plays the sound, you need to tell it to only play the sound if YOU touch it, not anyone else
01 | local finishPart = game.Workspace.Levels.Level 1. Checkpoints:WaitForChild( "Finish" ) |
02 | local plr = game.Players.LocalPlayer |
03 | local char = plr.Character |
04 | repeat |
05 | char = plr.Character |
06 | until char ~ = nil -- the reason why i do this is because the player's character might not be loaded in yet so it repeats this until it is loaded in |
07 |
08 | function onTouch (hit) |
09 | local H = hit.Parent : FindFirstChild( "Humanoid" ) |
10 | local S = game.Players.LocalPlayer.PlayerGui.Ding |
11 | if H ~ = nil and game.Players.LocalPlayer.Character.Humanoid = = H then |
12 | S:Play() |
13 | end |
14 | end |
15 |
16 |
17 | finishPart.Touched:connect(onTouch) |
this will make it so it checks to see that the person who touched it, is the character
01 | local finishPart = game.Workspace.Levels.Level 1. Checkpoints:WaitForChild( "Finish" ) |
02 | local plr = game.Players.LocalPlayer |
03 | local char = plr.Character |
04 | repeat |
05 | char = plr.Character |
06 | until char ~ = nil |
07 |
08 | finishPart.Touched:Connect( function (hit) |
09 | if hit and hit.Parent:FindFirstChild( "Humanoid" ) and hit.Parent = = char then |
10 | game.Players.LocalPlayer.PlayerGui.Ding:Play() |
11 | end |
12 | end ) |
^this is the way i would do it, they both should work the same way though tell me if there are any questions or this doesn't work
hope this helps!
Try to change this:
1 | local S = -- locate the sound inside the startergui. |
When there is something inside the startergui, it only replicated for that specific user. So placing the sound inside the startergui will make the sound play only for the player who touched the brick. Make sure you are referencing the sound correctly inside the local script.
01 | local SP = workspace:WaitForChild( "What is the part name you put it here" ) |
02 |
03 | function onTouch (hit) |
04 | local H = hit.Parent : FindFirstChild( "Humanoid" ) |
05 | local S = game.Players.LocalPlayer.PlayerGui.Ding |
06 | if H then |
07 | S:Play() |
08 | end |
09 | end |
10 |
11 |
12 | SP.Touched:connect(onTouch) |
if that doesn't work tell me