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: PLEASE HELP WITH DEBOUNCE

Previous Thread :: Next Thread 
DancingPillows is not online. DancingPillows
Joined: 02 Nov 2013
Total Posts: 96
16 May 2014 06:25 AM
local debounce = true
function OnClick()
if debounce == true then
debounce = false
if script.Parent.Parent.Thing1.Shop1.Value == 0 then
wait(1)
debounce = true
script.Parent.Parent.Thing1.Shop1.Value = 2
if script.Parent.Parent.Thing1.Shop1.Value > 0 then
if script.Parent.Parent.Thing2.Shop2.Value == 0 then
wait(1)
script.Parent.Parent.Thing2.Shop2.Value = 2
debounce = true
if script.Parent.Parent.Thing2.Shop2.Value > 0 then
print("OVERPASS")
wait(1)
debounce = true
end
end

end
end
end
end

script.Parent.MouseButton1Click:connect(OnClick)

I am trying to get a shop where if slot 1 is close, then it goes to shop 2. But for some reason, the 2 value goes to both of them. Any help? You can try my map to see it.
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
16 May 2014 06:33 AM
You use hell a lot of 'if' statements... try to lower that number of 'if's maybe its just confusing the script?
Report Abuse
robertjh12 is not online. robertjh12
Joined: 24 Feb 2008
Total Posts: 601
16 May 2014 06:49 AM
Ace, a thousand if statements wouldn't confuse a program, only the programmer.

DancingPillows your issue with the code is that your Debounce is not properly used. Your code declares that they both must get the value, because the statement will be true for them both. Read this over a few times and you may get it.

script.Parent.Parent.Thing1.Shop1.Value = 2
if script.Parent.Parent.Thing1.Shop1.Value > 0 then
if script.Parent.Parent.Thing2.Shop2.Value == 0 then
wait(1)
script.Parent.Parent.Thing2.Shop2.Value = 2

If your wish is to use debounce to stop multiple buys, please remove all debounce = true except from the end of the function.
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
16 May 2014 06:55 AM
Err Idk.. I would make it without so many 'if's...
Report Abuse
DancingPillows is not online. DancingPillows
Joined: 02 Nov 2013
Total Posts: 96
16 May 2014 04:08 PM
I know it isn't the if's problem. I made more script with more if's. It is only the debounce problem.
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