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

How can i check if a certain hotkey is being held, and when is it released?

Also how can i make some value rapidly increase while that button is being held?

1 answer

✓ Accepted answer

The answer is pretty simple. You can use the service "UserInputService" to sense when a key is being pressed. For example:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(key) -- Senses when a key is pressed
	if key == Enum.Key.Q then --Change Q to any key
		--Code
	end
end)

UserInputService.InputEnded:Connect(function(key) -- Senses when a key is let go
	if key == Enum.Key.Q then --Change Q to any key
		--Code
	end
end)

5 comments

0

Forgot to mention but you can constantly fire a remote event to increase the value

0

Thanks a lot that's exactly what i needed, could you also send me a link to the developer wiki explaining the whole user input service, i couldn't find it by myself

0

Sure, of course!

0

I'm thankful

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