Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I check if a key is no longer being pressed?

I want to make a sprint button. I know how to bind keys but I don't know how to make the function stop when the sprint button (left shift) is no longer being held down.

2 answers

✓ Accepted answer

For Client key down you should probably use UserInputService:

local user = game:GetService("UserInputService")
if user:IsKeyDown(Enum.KeyCode.A) then
	repeat
	wait(1)
	print("Key A is down")
	until not user:IsKeyDown(Enum.KeyCode.A) --- Will repeat until the key is not down.
end

This discussion is preserved as it was. New answers, comments, and votes are closed.