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

How do you ensure that a sound only plays for an individual user once, but can be played again?

Asked by 1 year ago

I am currently working on a game with a number of weapons, ones that are placed around the map as props and can be clicked to be picked up. As to ensure that users know exactly when they have picked up a weapon without having to check their inventory, I decided to try making a basic pick up sound system, one that is just four lines and can be seen below.

script.Parent.MouseClick:Connect(function()
    script.Parent.Sound:Play()

end)

While this individual script has been working fine, one of the issues that I have tried again and again to fix was ensuring that no players could stand by the weapon and spam it to create a constant pickup sound. The script was created with the intention that both the player who picked up the weapon and those around the map could all hear the item being picked up via the unique sound it provides. If I wanted to script it so only one person, the person who picked up the weapon, could hear the sound-- I would've tried to. However, I'm not quite sure how to ensure that the one person who picked up the weapon in the first place cannot play the sound again until death without the possibility of making a sound cooldown for everyone in the server. I've thought about trying to use a LocalScript to run an event to play a sound, but given the fact that each pickup sound is unique, trying to create a script in this way with my basic scripting only resulted in a bunch of RemoteEvents and a script that didn't even work because of my lack of knowledge as to how to even make a sound only play once for one player. As a result, after a few days of trying to find out what was going on, I just went back to the basic original script above. I don't remember what the script I used for the RemoteEvents looked like, but I'm probably going to try to recreate it anyways.

0
I have never posted a question here, so pardon if it comes off as strange or cluttered. Alainlove100 0 — 1y
0
try and add a debounce? Xx_ashcarter13 17 — 1y

Answer this question