Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Bind an action using a value as the key? Not working...

I'm attempting to bind an action using a value as the key needed. It's not working... From what I see in the console, there shouldn't be a problem with it.

So my question is this: Am I doing somthing wrong or is this a possible Roblox bug, and if so, how do I proceed?

/(The value of "KEY" (a string value) is "Enum.KeyCode.E")/

local Context_Service =game:GetService("ContextActionService")

Context_Service:BindAction("Name",Function,false,workspace.KEY.Value)

Pressing "E" does absolutely nothing, the function will not fire.

2 comments

0

Why are you using workspace.KEY.Value instead of Enum.KeyCode.E?

0

Because I want to change the "KEY" value as a sort of control customizer. A player can change what buttons do what.

1 answer

✓ Accepted answer

Can't test it right now, but hopefully it works. Let me know if it doesn't.

local Context_Service = game:GetService("ContextActionService")
local keyValue = game.Workspace.KEY.Value

Context_Service:BindAction("Name", Function, false, Enum.KeyCode[keyValue])

2 comments

0

Yup, that works! Thanks.

0

No problem! Anytime :)

This discussion is preserved as it was. New answers, comments, and votes are closed.