Context Action Service not printing the KeyCode

  1. What do you want to achieve? I’m trying to make a sprint button on the game for mobile players, so I’m learning how to use the Context Action Service

  2. What is the issue? Base on “Creating Mobile Buttons”, the fourth parameter of Context Action Ser. is the “InputTypes” or “the inputs you want to bind to the function, for instance enum values from KeyCode.”. But when I try printing out which button was pressed

local function handleAction(actionName, inputState, inputObject)
	if inputState == Enum.UserInputState.Begin then
		print(actionName, inputObject.KeyCode)
	end
end

-- Bind action to function
contextaction:BindAction("Interact", handleAction, true, Enum.KeyCode.T)

(the script is from the article btw)

it outputs this

Interact Enum.KeyCode.Unknown - Client - BaseLocalScript:23

  1. What solutions have you tried so far? Tried researching more about it but still can’t find any solution

oh and btw while using the emulator I always keep getting these errors

1 Like

I personally did some research about contextactionservice myself and found nothing about detecting if a input is from a mobile device as of currently.

Some alternatives would be to:

yeah just made my script simpler, but sadly can easily be bypassed. I just removed the line of code that checks if the button that is pressed is equals to left shift, but overall it works fine now. just the error I kept getting when using the emulator