I've been trying to make it so if the player continues to hold down left shift, there speed will continuously increase. Just can't seem to get it to work. If I hold down left shift the playerSprintSpeed stays the same, even though when i'm printing the speed it goes up. I'm a total noob when it comes to roblox scripting so any help is appreciated. Thanks!
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local UserInputService = game:GetService("UserInputService")
local defaultSpeed = 16
local leftShift = Enum.KeyCode.LeftShift
local leftShiftDown = false
local playerSprintSpeed = 16
UserInputService.InputBegan:Connect(function(key)
if key.KeyCode == leftShift then
character.Humanoid.WalkSpeed = playerSprintSpeed
leftShiftDown = true
end
end)
UserInputService.InputEnded:Connect(function(key)
if key.KeyCode == leftShift then
character.Humanoid.WalkSpeed = defaultSpeed
print(character.Humanoid.WalkSpeed)
end
end)
while wait() do
if leftShiftDown then
print("yes...")
playerSprintSpeed = playerSprintSpeed + 1
print(playerSprintSpeed)
else
print("no...")
end
end

3 comments
Once the press shift, it will continuously say yes, cause you never made "leftShiftDown" false again
Your while loop should be within your InputBegan function.
Also, playerSprintSpeed is 16