Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Play sound locally when a GUI is clicked?

Does anybody know a script for when a GUI is clicked, a sound is played locally to the player and nearby players

2 comments

1

This is not a request site.

0

Putting a sound into the players gui, will play the sound locally.

1 answer

You would need to write the script, but this is how I would go about it. First make a Local Script and put a Sound Object inside it. Write the script so that when the script runs it will play what ever the Sound is. Then disable that script and put it somewhere to be cloned later.

Write in your main script when the button is clicked to loop through the players and to check their Distance from where the person who click it's Position. Using magnitude

local Distance = (a.Position-b.Position).magnitude -- the distance between a and b in studs

If it's confirmed that Distance is less then how far you want them to be. Then clone that script, change it's SoundId into the sound effect you want and send into their player and play it. I also recommend to have a :Destroy(script) on the cloned script's functions. So they don't build up over time. Hope this Method helps or you were able to replicate it. Best of Luck!

This discussion is preserved as it was. New answers, comments, and votes are closed.