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

Binding multiple keys to the same function in ContextActionService doesn't work?

Asked by 3 years ago
Edited 3 years ago

I've bound a function to my M1 like this:

-- Bind keys to contextactionservice
local ctx = game:GetService("ContextActionService");
-- M1
ctx:BindAction("attack", handleInput, true, Enum.UserInputType.MouseButton1);
ctx:SetTitle("attack", "M1")
ctx:SetImage("attack", "rbxassetid://7333318354");
ctx:GetButton("attack").Position = UDim2.new(0.5, 0, 0.4, 0);
ctx:GetButton("attack").Size = UDim2.new(0, 95, 0, 95);

It works fine, but the following bindings won't trigger at all. The function does not even get called. I also binded the function to KeyCodes, but I'll only post one example here.

ctx:BindAction("primary", handleInput, true, Enum.UserInputType.MouseButton2);
ctx:SetTitle("primary", "M2")
ctx:SetImage("primary", "rbxassetid://7333318354");
ctx:GetButton("primary").Position = UDim2.new(0.25, 0, 0.1, 0);

Any idea as to why this is happening?

0
GetButton() yields infinitely. This is a studio bug which have not been fixed. I highly recommend for you to make your own GUI, as CAS isn't to be trusted. Hockeycon2012 -4 — 3y

Answer this question