I am trying to make the Spam Keybind System. Something like this :
Here’s my script [Just incase] :
local pressing = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
value.Value = value.Value + 0.122
bar:TweenSize(UDim2.new(value.Value, 0, 1, 0), 'Out', 'Quint', .1, true)
pressing = true
while value.Value < 1 and pressing do
value.Value = value.Value - 0.01
bar:TweenSize(UDim2.new(value.Value, 0, 1, 0), 'Out', 'Quint', .1, true)
if value.Value < 0 then
value.Value = 0
bar:TweenSize(UDim2.new(0, 0, 1, 0), 'Out', 'Quint', .1, true)
end
if value.Value >= 1 then
event:FireServer()
guis.Enabled = false
break
end
task.wait(0.15)
end
end
end)
I understand that putting the while loop in the InputBegan is a bad idea. Whenever I press it, it will start a new loop which will compete with the other already starting loop. How can I make the Spam Keybind System? [ I am making it go down whenever the player stops pressing the space bar ]