Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Spam clicking the tool makes the loop increase a value rapidly. Why?

Asked by 5 years ago
Edited 5 years ago

I made a tool where if I hold it down, it increases a value. It works, but if I spam click it and immediately hold the mouse button down the value increases rapidly as if I never put a wait() there.

Here is my code:

01script.Parent.Activated:Connect(function()
02    script.Parent.Charging.Value = true
03    while script.Parent.Charging.Value==true do
04        if script.Parent.Charging.Value==false then
05            break
06            end
07            script.Parent.Charge.Value = script.Parent.Charge.Value +10
08            print ("obama")
09            wait(1)
10            if script.Parent.Charging.Value==false then
11                break
12        end
13    end
14end)
15 
View all 21 lines...
0
I forgot to add a debounce. Nevermind. RoblotXRB 3 — 5y
0
I don't recommend using while script.Parent.Charging.Value==true do raid6n 2196 — 5y
0
You need to explain the script more raid6n 2196 — 5y

Answer this question