Hold Shift to Sprint help

So, I have everything down as far as the script working goes, it works perfectly, but there is a problem, right now I am using 2 functions, where pressing shift will make your speed faster, and pressing Q will return you to the default speed, but I need a sort of key code that means nothing is being pressed on the keyboard, and I am a bit confused as to how I would go about doing that, my script:

--prTESTAQ


local player = game.Players.LocalPlayer
local char = player.Character
local UIS = game:GetService("UserInputService")
local sped = 36

UIS.InputBegan:Connect(function(key)

if key.KeyCode == Enum.KeyCode.LeftShift then
	char.Humanoid.WalkSpeed = sped
	
	
end



end)


UIS.InputBegan:Connect(function(key)

if key.KeyCode == Enum.KeyCode.Q then

	char.Humanoid.WalkSpeed = 16

end

end)
2 Likes

Instead of using Q, you could use the event InputEnded from a key pressed and then return the player to the default speed

1 Like

Oml, I’m so stupid, I accidentally changed it to InputBegan oh man, I need to rethink life

Thank you for this.

1 Like