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 4 years ago
Edited 4 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:

script.Parent.Activated:Connect(function()
    script.Parent.Charging.Value = true
    while script.Parent.Charging.Value==true do 
        if script.Parent.Charging.Value==false then 
            break
            end
            script.Parent.Charge.Value = script.Parent.Charge.Value +10
            print ("obama")
            wait(1)
            if script.Parent.Charging.Value==false then 
                break 
        end
    end
end)

script.Parent.Deactivated:Connect(function()
    print ("Nobama")
    script.Parent.Charging.Value = false
    wait(0.5)
    script.Parent.Charge.Value = 0
end)
0
I forgot to add a debounce. Nevermind. RoblotXRB 3 — 4y
0
I don't recommend using while script.Parent.Charging.Value==true do raid6n 2196 — 4y
0
You need to explain the script more raid6n 2196 — 4y

Answer this question