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
Thank you in advance !
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)
Put the script inside a local script, inside the startergui. Then refer to is as workspace.(part)
That way only the player that touched it can hear it.
@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