As you can see in the title, my question is simple. For UserInputService, how do make a hold input? As pro developers must have seen, UIS is really chunky. You have to keep pressing that button rapidly and repeatedly. How do we make a hold input? Like in a normal roblox character, you HOLD "W" to move. How is that? Is there a way to write it in code?
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | local aKeyPressed = false |
03 |
04 | UserInputService.InputBegan:Connect( function (input,GameProcessedEvent) |
05 | if input.KeyCode = = Enum.KeyCode.A then |
06 | aKeyPressed = true |
07 |
08 | while aKeyPressed = = true do |
09 | wait() |
10 | print ( "A-Key is being held down!" ) |
11 |
12 | end |
13 | end |
14 | end ) |
15 |
16 | UserInputService.InputEnded:Connect( function (input,GameProcessedEvent) |
17 | if input.KeyCode = = Enum.KeyCode.A then |
18 | aKeyPressed = false |
19 | end |
20 | end ) |