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: Why does this happen more than once with a debounce?

Previous Thread :: Next Thread 
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
10 Jun 2014 02:51 PM
confirm.Buy.MouseButton1Down:connect(function()
print("c")
local debounce = false
if player.leaderstats.Robux ~= nil then
if debounce == false then
debounce = true
print("a")
if player.leaderstats.Robux.Value >= price then
print(price)
player.leaderstats.Robux.Value = player.leaderstats.Robux.Value - price
print("b")
end
debounce = false
end
end
end)

--(Everything is defined)
Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
10 Jun 2014 02:52 PM
perhaps you should add a wait in the middle and see if it changes anything?
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
10 Jun 2014 02:54 PM
forgot to put in the wait while pasting this script
(its part of a script)

confirm.Buy.MouseButton1Down:connect(function()
print("c")
local debounce = false
if player.leaderstats.Robux ~= nil then
if debounce == false then
debounce = true
print("a")
if player.leaderstats.Robux.Value >= price then
print(price)
player.leaderstats.Robux.Value = player.leaderstats.Robux.Value - price
print("b")
end
wait(1)
debounce = false
end
end
end)
Report Abuse
spynaz is online. spynaz
Joined: 17 Feb 2011
Total Posts: 1326
10 Jun 2014 02:54 PM
Becuase you made the debounce a local variable within the scope of the event. You gotta do this:

local debounce = false

confirm.Buy.MouseButton1Down:connect(function()
print("c")
if player.leaderstats.Robux ~= nil then
if debounce == false then
debounce = true
print("a")
if player.leaderstats.Robux.Value >= price then
print(price)
player.leaderstats.Robux.Value = player.leaderstats.Robux.Value - price
print("b")
end
debounce = false
end
end
end)
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
10 Jun 2014 02:56 PM
still repeats multiple times even with the wait
Report Abuse
spynaz is online. spynaz
Joined: 17 Feb 2011
Total Posts: 1326
10 Jun 2014 02:58 PM
Well it should work, were are you putting the wait function?
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
10 Jun 2014 02:59 PM
local debounce = false

confirm.Buy.MouseButton1Down:connect(function()
print("c")
if player.leaderstats.Robux ~= nil then
if debounce == false then
debounce = true
print("a")
if player.leaderstats.Robux.Value >= price then
print(price)
player.leaderstats.Robux.Value = player.leaderstats.Robux.Value - price
print("b")
end
wait(1)
debounce = false
end
end
end)

this is part of a global function if that makes a difference
Report Abuse
spynaz is online. spynaz
Joined: 17 Feb 2011
Total Posts: 1326
10 Jun 2014 02:59 PM
Nvm I see where you put it in your last post.
Report Abuse
spynaz is online. spynaz
Joined: 17 Feb 2011
Total Posts: 1326
10 Jun 2014 03:06 PM
I'm not really sure why, if it just prints "c" a lot of times then that's fine because you didn't put it within the "if debounce == false" statement.
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
10 Jun 2014 03:09 PM
want the whole global function and the script that activates the function?
Report Abuse
spynaz is online. spynaz
Joined: 17 Feb 2011
Total Posts: 1326
10 Jun 2014 03:22 PM
Sure.
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