So I'm trying to use ContextActionService to bind keys for certain functions, however, I can't seem to use the same keys and I don't want to use different keys :

local cas = game:GetService("ContextActionService")

local function onpress()
print("first")
end

local function onpress2()
print("second")
end

cas:BindAction("onpress", onpress, false, "f"
cas:BindAction("onpress", onpress2, false, "f"

6 comments

0

You cannot bind two actions to the same key, only the most recently bound action will fire. Also, I'm not sure you can use "f" instead of Enum.KeyCode.F.

0

then how do popular roblox games do it and yes you can use f instead of enum.keycode

0

Okay, I didn't know that. I've always used Enum for it. Most games probably don't use ContextActionService for this and instead use UserInputService and do the same function for the same input.

0

how

2

Maybe adding an if statement in the second function asking if the first function was run to go along with running the second function

0

that actually worked thank you