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.
For Client key down you should probably use UserInputService:
1 | local user = game:GetService( "UserInputService" ) |
2 | if user:IsKeyDown(Enum.KeyCode.A) then |
3 | repeat |
4 | wait( 1 ) |
5 | print ( "Key A is down" ) |
6 | until not user:IsKeyDown(Enum.KeyCode.A) --- Will repeat until the key is not down. |
7 | end |
Use a UserInputService and events InputBegan & InputEnded
Service: http://robloxdev.com/api-reference/class/UserInputService