✓ Accepted answer
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
local finishPart = game.Workspace.Levels.Level1.Checkpoints:WaitForChild("Finish")
local plr = game.Players.LocalPlayer
local char = plr.Character
repeat
char = plr.Character
until char ~= nil
function onTouch (hit)
local H = hit.Parent : FindFirstChild("Humanoid")
local S = game.Players.LocalPlayer.PlayerGui.Ding
if H ~= nil and game.Players.LocalPlayer.Character.Humanoid == H then
S:Play()
end
end
finishPart.Touched:connect(onTouch)
this will make it so it checks to see that the person who touched it, is the character
local finishPart = game.Workspace.Levels.Level1.Checkpoints:WaitForChild("Finish")
local plr = game.Players.LocalPlayer
local char = plr.Character
repeat
char = plr.Character
until char ~= nil
finishPart.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") and hit.Parent == char then
game.Players.LocalPlayer.PlayerGui.Ding:Play()
end
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!
2 comments
Local scripts only work in StarterPlayerScripts, StarterPack, StarterGui or StarterCharacter so you can't put it into the part itself, change all references of the part to something like workspace:WaitForChild("Part")
@imKirda I edited to what you told me to do. The sound plays. But, it plays for everyone in the server, not just the player that touched the part. Please help.