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?
✓ ANSWER ACCEPTED
How do we do a Hold UIS function?
1 answer
✓ Accepted answer
local UserInputService = game:GetService("UserInputService")
local aKeyPressed = false
UserInputService.InputBegan:Connect(function(input,GameProcessedEvent)
if input.KeyCode == Enum.KeyCode.A then
aKeyPressed = true
while aKeyPressed == true do
wait()
print ("A-Key is being held down!")
end
end
end)
UserInputService.InputEnded:Connect(function(input,GameProcessedEvent)
if input.KeyCode == Enum.KeyCode.A then
aKeyPressed = false
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
Wow, thanks! I'll try that out later!
Instead of the print ("A-Key is being held down!") insert anything you want it to do.
And at line 5, just change the last letter to whatever you want. I did it with A but you can just remove this A and put Z in there, for example and this event will happen, when you press Z.
I know lol :)
I'm not too familiar with this but wound't using inputEnded be a better solution?
@synkrio what do you mean? I did use InputEnded, line 16. I'm not too familiar with this too, I just know that this works.