I'm making a menu GUI in my game, and would like to have them press M for it to open. I've tried a few times and can't grasp it. I'm really new to this and would like some help. Thanks :)
COMMUNITY QUESTION
KeyDown function to enable GUI?
1 answer
For more info about this type of stuff: https://developer.roblox.com/en-us/articles/Keyboard-Input-Methods Using the example from here, this is what I would do (localscript)
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
game.Players.LocalPlayer.PlayerGui.replacewithgui.Enabled=true
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
Hope it helps, if it did be sure to accept the answer!
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
Wait so, where do i put the reaction for the GUI to enable?
ah, i see the "replacewithgui" my bad. im just blind aha
Didnt work, thanks though. ;-;
Reason why that didn't work is because he's missing an "s" after game.Player, it's supposed to be game.Players. Also make sure that you put this code in a Local Script inside of the GUI, and change "Enum.KeyCode.R" to "Enum.KeyCode.M" if you want. (just changes what button you press to activate the GUI)
if this works im gonna be mad at myself
lmao @godlydeath I saw that, fixed the typo.