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

Some buttons in KeyDown?

I've noticed that the KeyDown event won't fire when you press the letters O and I. I'm assuming this is because these are the shortcuts to zoom in or out. How can I make it so the KeyDown event fires when I press O or I? NOTE: I NEED IT TO RETURN WHAT KEY WAS PRESSED (Which was O or I).

I'm not asking/requesting for a script to be made, I just want to know how I can do this.

1 answer

I had the same problem just a few days ago, and the solution was to use the KeyUp()event instead of KeyDown(). I'm not entirely sure why KeyUp works while KeyDown doesn't, but it does work.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
function keyUp(key)
	print(key)
end
mouse.KeyUp:connect(keyUp)

4 comments

0

Is there any way I can let it work with KeyDown? Because the player has to hold down O, and it stops running when he lets go of O.

0

Yeah key down works, but some keys are blocked so that's probably the reason.

0

@Perci I think KeyDown doesn't work because ROBLOX have made the KeyDown event for O and I reserved for the zoom in/out functions.

0

I do not know of any way to make it work for KeyDown. You MIGHT find something in the UserInputService, but I know nothing about it. http://wiki.roblox.com/index.php?title=UserInputService

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