0

# How to trigger a sound when a player touch a part but only him can hear the sound?

I wanted to make a script that run a sound when a player walk on a part so I have made this script :

script.Parent.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
script.Parent.Playing = true
end
end)


This script work but everyone can hear the sound, I wanted to play the sound Locally so i tried to put the exact same code into a LocalScript but now, i can't hear anything !

The script is in the sound and the sound is in a part

0

You need a remoteevent (put it in replicatedstorage or something)

script on the part:

script.Parent.Touched:Connect(function(hit)
if hit.Parent.Humanoid then
game.ReplicatedStorage.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent),script.Parent)
end
end)


insert a localscript on startergui. script for the local script:

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(part)
part.Sound.Playing = true
end)

0
Thank you for your answer @jdm4llfem8 It's working I just need a friend to test if he can hear or not the sound xD Louix27626 83 — 1y
0
If i want to add a debounce where do I add it? Louix27626 83 — 1y
0
im gonna edit the answer so you can see jdm4llfem8 94 — 1y
0
Actually no i cant, but you have to put it on the script, not the local script jdm4llfem8 94 — 1y
0
@ThePoint13, I took my script, put it into a LocalScript in the StarterGui but where do I put the Sound and do i need to put something in the LocalScript or it can stay empty