Here's the script. I don't know why it isn't working, but it may have to do with the fact that I'm including two "inputObject"s.
local player = game.Players.LocalPlayer
function onKeyPress(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin then if inputObject == Enum.KeyCode.Z then print("Inventory being accessed...") player.PlayerGui.Inventory.Frame.Visible = true elseif inputObject == Enum.KeyCode.X then print("This isn't implemented yet! :o") end end end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Z or Enum.KeyCode.X)
This is new to me, so assistance is greatly appreciated!! -kon
But nevermind my comment, I still want to help you. (Btw, Code block is a blue Lua button on top when you are asking a question)
You are checking
if inputObject == Enum.KeyCode.Z then
While inputObject does have a variable associated to it that holds the KeyCode, you must access it first, like this:
if inputObject.KeyCode == Enum.KeyCode.Z then
You are also trying to bind multiple keys to a single function. To do this, you actually have to bind the whole keyboard, like this:
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.UserInputType.Keyboard)
Everything else seems good, so if you have no more errors in code that you didn't post, this should work.
Hope this helped.