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:
01 | script.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 |
07 | script.Parent.Charge.Value = script.Parent.Charge.Value + 10 |
10 | if script.Parent.Charging.Value = = false then |
16 | script.Parent.Deactivated:Connect( function () |
18 | script.Parent.Charging.Value = false |
20 | script.Parent.Charge.Value = 0 |