I'm trying to make a running script where every 2 seconds of you holding Shift your WalkSpeed goes up by 1 until it reaches 25
After I stop holding shift the animation ends but it keeps going up until 25 even though I'm not holding Shift
local p = game.Players.LocalPlayer local char = p.Character if not p.Character then repeat wait() until p.Character end local human = char.Humanoid local anim = game.Workspace:WaitForChild("Animation") local loadAnim = human:LoadAnimation(anim) local UIS = game:GetService("UserInputService") local holdingShiftKey = false UIS.InputBegan:Connect(function(inputObject) if(inputObject.KeyCode==Enum.KeyCode.LeftShift)then holdingShiftKey = true while holdingShiftKey do loadAnim:Play() repeat wait(2) char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 1 until char.Humanoid.WalkSpeed == 25 end end end) UIS.InputEnded:Connect(function(inputObject) if(inputObject.KeyCode==Enum.KeyCode.LeftShift)then holdingShiftKey = false char.Humanoid.WalkSpeed = 16 loadAnim:Stop() end end)
Does anyone have a fix for this?
u never added anything to stop the repeat until , so it keeps on doing that until it reaches the exit condition
repeat wait(2) char.Humanoid.WalkSpeed += 1 until char.Humanoid.WalkSpeed == 25 or not holdingShiftKey