Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Play sound locally when a GUI is clicked? [closed]

Asked by 5 years ago

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

1
This is not a request site. DeceptiveCaster 3761 — 5y
0
Putting a sound into the players gui, will play the sound locally. BuDeep 214 — 5y

Closed as Not Constructive by MachoPiggies, LukeSmasher, and xPolarium

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 5 years ago

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!

Ad