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.
✓ ANSWER ACCEPTED
How do I check if a key is no longer being pressed?
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
Use a UserInputService and events InputBegan & InputEnded
Service: http://robloxdev.com/api-reference/class/UserInputService
This discussion is preserved as it was. New answers, comments, and votes are closed.
