UIS or CAS - Which should i use?)

I’ve used both User Input Service, and Context Action Service. They both seem to do the same thing, just in different ways. I saw that you could bind and unbind with CAS, which i guess could help stop memory leaks? I also saw with UIS that you can check when the input is started and ended, which to my knowledge is not possible with CAS.

Which is better to use, or does it depend on context? I personally find CAS a bit more organised, but I’ve not used either very much. What are more of some of the differences?

(I also like with CAS i dont have to check what the input is, i can just define it when its binded.

This just depends on API it self and your knowledge with it.
It is possible actually check when the input is started or changed or ended with CAS.

You probably had code which didn’t had second argument (Enum.UserInputState).

BindAction provides three arguments such as string, Enum.UserInputState ,InputObject to function which handled on Bind

1 Like

Personally i prefer UIS because it gives me more control and i don’t like how CAS stores all your binded actions in a global table.

I don’t think one is objectively better than the other though. It’s more of a preference thing.

You probably want to look at Input Action System (IAS). It’s a new way of detecting input.
Although i haven’t used it yet it looks quite nice

2 Likes

Avoid using ContextActionService in new work. It is being sunset in favor of the Input Action System. Use UIS and/or IAS.

1 Like

Use InputAction its easier than both:

https://create.roblox.com/docs/input/input-action-system

When this came out, the announcement said ContextAction is deprecated and is planned to be discontinued but UserInputService will still be supported.

Step 1: Add “InputContet” object into somewhere the client can access (ex. StarterGui, StarterCharacter). This can be enabled or disabled (ex. attack input is disabled for intermission).

Step2: Add “InputAction” into InputContext and name it what you want. (ex. PunchInput)

Step3: Add “InputBinding” into InputAction and set the KeyCode (ex. E). You can add multiple InputBindings for other inputs and its the same for controller/touchscreen gui)

Step4: Scripting
ex.
InputContext.PunchAction.Pressed:Connect(function()
–code
end)

1 Like