local UIS = game:GetService("UserInputService")
local LShiftonHold = false
UIS.InputBegan:Connect(function(input, gameProccessEvent)
if input.KeyCode == Enum.KeyCode.LeftShift then
LShiftonHold = true
end
end)
UIS.InputEnded:Connect(function(input, gameProccessEvent)
if input.KeyCode == Enum.KeyCode.LeftShift then
LShiftonHold = false
end
end)
while LShiftonHold == true do
wait()
script.Parent:WaitForChild("Humanoid").WalkSpeed = 100
end
Remember that while loops only run once and break once. Your loop does not run at all because no matter what, LSiftonHold is false when the condition “LSiftonHold == true” is checked. So the loop will not run at all. There’s a simple fix for this! You just run the loop whenever LSiftonHold is on. So, like this:
local UIS = game:GetService("UserInputService")
local LShiftonHold = false
UIS.InputBegan:Connect(function(input, gameProccessEvent)
if input.KeyCode == Enum.KeyCode.LeftShift then
LShiftonHold = true
while LShiftonHold == true do
wait()
script.Parent:WaitForChild("Humanoid").WalkSpeed = 100
end
end
end)
UIS.InputEnded:Connect(function(input, gameProccessEvent)
if input.KeyCode == Enum.KeyCode.LeftShift then
LShiftonHold = false
end
end)