|
| 04 Dec 2012 12:19 PM |
Hey guys, I have a sound which I want to swap when I press a button, it all works, no output errors but it plays the song again after it. I tried using debounce but to no success and I am unsure what to do. Any help is appreciated. Script:
button = script.Parent
function onClicked() if not debounce then debounce = true for _, player in pairs(game.Players:GetPlayers()) do button.BrickColor = BrickColor.Green() player.Sound:Remove() game.Lighting.Music.Payphone:Clone().Parent = player player.Payphone.Name = "Sound" player.Sound.Volume = 0.6 wait(1) button.BrickColor = BrickColor.Red() player.Sound:Play() wait(2) debounce = false end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2012 12:31 PM |
| Allow me to clarify, the sound plays and a few seconds after, the same sound starts to play under the other sound. How do I get this to stop? |
|
|
| Report Abuse |
|
|
| |
|
gamehero
|
  |
| Joined: 12 Jun 2007 |
| Total Posts: 1455 |
|
|
| 04 Dec 2012 01:28 PM |
| Does it only do this when more than one players are in the map? Then that would be part of the problem. Also, the sounds aren't in the PlayerGui to play locally if that's what you're trying to do. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2012 01:33 PM |
| The sounds are in PlayerGui so I can turn off the music when the player leaves the room (In this case, my club) so basically, it's playing it locally. Also, I have only tested this on server mode and not online and it still does this. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 05 Dec 2012 11:05 AM |
Did you even declare the debounce object? Put this at the top:
debounce = false
- thedestroyer115 |
|
|
| Report Abuse |
|
|
gamehero
|
  |
| Joined: 12 Jun 2007 |
| Total Posts: 1455 |
|
|
| 05 Dec 2012 11:09 AM |
| Ok, after testing local sounds with PlayerGui, I see it will have to play inside Soundscape instead. But the script to create and play the sound will have to be a local script, and you may need to use an IntValue or a BoolValue inside the Player object for the server to communicate with them. |
|
|
| Report Abuse |
|
|