I know what you’re thinking!
You think I left the parenthesis in, like this:
ContextActionService:BindAction("BeginLevel", startLevel(), false, Enum.KeyCode.E)
But no.
I am trying to bind an action which will make something not cancollide, but for testing purposes, “BeginLevel” unbinds the action and prints “Key E Pressed!”
However, in a different function which is called based off of a touched event prints E before I have hit the key!
Here are some code samples:
restartLevel.OnClientEvent:Connect(function(levelToSet) -- The remote event fires from a seperate hitbox touched event.
restartLevelFunction(levelToSet)
end)
Then:
local function restartLevelFunction(levelToRestart)
-- Do some stuff to set up the level
contextActionService:BindAction("BeginLevel", startLevel, false, Enum.KeyCode.E)
end
Then:
local function startLevel()
contextActionService:UnbindAction("BeginLevel")
print("Key E pressed!")
end
Here is a gif of the problem. The Localization Tools error is a studio bug, as you probably already know if you are reading this soon after me writing it.
https://gyazo.com/0556a000ff313d50358c4e3a9707241e
Thanks in advance!