|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|