generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Sound plays twice when clicking a button

Previous Thread :: Next Thread 
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
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
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
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
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
04 Dec 2012 12:54 PM
Anyone?
Report Abuse
gamehero is not online. 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
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
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
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
04 Dec 2012 02:32 PM
Bump!
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
05 Dec 2012 10:34 AM
Please help guys
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
05 Dec 2012 11:05 AM
Did you even declare the debounce object? Put this at the top:

debounce = false

- thedestroyer115
Report Abuse
gamehero is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image