What are these Variables doing?

Started practicing ContextActionService using a youtube tutorial and the wiki arcticle and there are these two variables that I just can’t understand already tried reading some articles about what they are specifically but I just can’t wrap my head around it :

The entire script:

The variables:

  • Any help/explanation is really appreciated :relaxed:
2 Likes
  • actionName is the name of the action that was performed, which is the string passed as the first argument of BindAction. Say you have this: ContextActionService:BindAction("OpenDoor", functionHere, false, Enum.KeyCode.E, when the E key is pressed, the function passed in the BindAction function will be called and the first parameter of the function, in your case actionName, will be “OpenDoor”.

  • inputState is an enumeration that indicates the state of the input, whether it is just pressed (Begin enum item), changed (Change enum item), or released (End enum item). If you bind an action to the R key and you press the key, the 2nd parameter of your function, in your case inputState, will be Enum.UserInputState.Begin, and as you release it, it’ll be Enum.UserInputState.End. Here’s a wiki page on the UserInputState enum

  • inputObject holds information about the input that was made. You can check its type, the key pressed, state is also included. If you interact with the R key on your keyboard, the 3rd parameter of your function in the BindAction function, in your case inputObject, will have its KeyCode be Enum.KeyCode.R, and UserInputType will be Enum.UserInputType.Keyboard. Here’s a wiki page on the InputObject class

3 Likes

Thanks, really appreciate it :slight_smile:

1 Like

and what is about the true or false, between function name and the keycode?

It determines whether or not a gui button is created for devices that support touchscreen input – true for it to be created, false otherwise

1 Like