Answered by
7 years ago Edited 7 years ago
We can do this by using a remoteevent
First create a remoteevent and place it somewhere like the workspace or inside the clickdetector
Now let's work on the Script that fires when someone clicks, i will merge the function and where you call it together. Make sure you change the re variable to where the remoteevent is
1 | local re = script.RemoteEvent |
3 | script.Parent.ClickDetector.MouseClick:connect( function (plr) |
I fired the remoteevent with the player
Next we will create a LocalScript inside startergui, also change the sound variable to where the sound is located inside the startergui, playing this will make it so that only the player can hear it. You will also need to point the re variable to where the remoteevent is located
1 | local re = workspace.Part.ClickDetector.Script.RemoteEvent |
2 | local sound = script.Parent.Sound |
4 | re.OnClientEvent:connect( function () |
When the remoteevent is fired towards the player the function will fire and it will play the sound. only the player who is firing the function can hear it because the sound is inside their playergui.