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

How do I properly 'keybind' this script?

Asked by 8 years ago

I've been using 'keybinds' in local scripts and they seem to work fine. The only issue is that: these 'keybinds' activate even when typing in the chat. I'm using UserInputService. Perhaps I should be using something else or perhaps I've been taking the wrong approach? Here is the script.

function KeyDown(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.F and InventoryOpened == false then
        (Insignificant stuff)
    end
end




game:GetService("UserInputService").InputBegan:connect(KeyDown)

I appreciate the help.

0
What do you mean they activate even when typing in the chat? KingLoneCat 2642 — 8y
0
Your title is a bit misleading, your script checks key input and does not keybind. For Keybinding you need to use the "ContextActionService" to bind an action to an input. An example can be found if you run studio as a test the navigate to starterPlayer->StarterPlayerScripts->ControlScript->MasterControl->KeyboardMovement User#5423 17 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

GameProcessedEvent
Did you see that?

The gameProcessedEvent argument of the UIS events tell you whether the input was directed to the game or whether it was intercepted by something such as a TextBox. Check that to see if the user is typing, and then return out of the function if they are.

Ad

Answer this question