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

bind the same key to different actions? [SOLVED] Edit:you can also use debounce

Asked by 3 years ago
Edited 3 years ago

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"

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. radiant_Light203 1166 — 3y
0
then how do popular roblox games do it and yes you can use f instead of enum.keycode mishokirva 22 — 3y
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. radiant_Light203 1166 — 3y
0
how mishokirva 22 — 3y
View all comments (2 more)
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 Zripple 18 — 3y
0
that actually worked thank you mishokirva 22 — 3y

Answer this question