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

How do I know if a key is pressed?

1 answer

✓ Accepted answer

To find how long it is pressed for you would set a variable to tick() in your KeyDown function like so:

mouse=  --(However you're getting the mouse)

mouse.KeyDown:connect(function(key)
	--Do whatever you want with that key here
	pasttime=tick()
end)

Then in your KeyUp function would set another variable to tick() and subtract the pasttime variable from the variable you just set. Example:

mouse.KeyDown:connect(function(key)
	--Do whatever you want with that key here
	currenttime=tick()
	keytime=currenttime-pasttime
end)

The keytime variable would be the time the key is pressed.

1 comment

0

Please accept my answer.

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