Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use ContextActionService?

Asked by 7 years ago

I have the following code in a localscript which doesn't respond when I press a or d on the keyboard. I haven't tried a gamepad yet, but want to use this so I'm ready for game pad compatibility in my game. Nothing gets printed and the event is not invoked.

local function leftFunction(actionName, state, inputObject)
    if state == Enum.UserInputState.Begin then
    --  print("I only print on the begin event")
        print("go left began!")
    end
    print("go left!")
    rfx:InvokeServer("left")
end

game:GetService("ContextActionService"):BindActionToInputTypes("left", leftFunction, false, "a", Enum.KeyCode.DPadLeft)

Answer this question