Ad
Log in to vote
1

Input keycode triggers when I chat, I just want it when they hit the key. Can anyone help?

Asked by 13 days ago

Below is my code, I don't want this to trigger when the player is chatting but I do want it to when they hit the key though.

function onKeyPressed(inputObject, gameProcessEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then
        print("E")
0
Use the 'GameProcessedEven't boolean................... Ziffixture 6785 — 13d

2 answers

Log in to vote
0
Answered by
esepek 103
13 days ago

Hey there, there is a preatty easy solution for that! You can use the context action service in roblox, so it wont trigger when you write in chat.

Here is the link to ContextActionService: https://developer.roblox.com/en-us/api-reference/class/ContextActionService.

I hope I could help you out. If you need any help implementing it into your systeme, make sure to contact me, so I can help you out. Have a nice day, esepek.

0
You have to be kidding me. You do realize that there is a parameter supplied to the 'InputBegan' Callback that can debounce this... You have no need to shift to entirely new Service. Ziffixture 6785 — 13d
0
Well I think CAS is the best solution in this case. Not only can you solve the current problem but its much easyer to define when certain inputs should have an effect or not. And YES you could check if another script has already processed the input , but why wouldnt you just go with CAS in the first place? I mean what if he wants to add Mobile buttons?? I think CAS is the better solution here! esepek 103 — 13d
Ad
Log in to vote
0
Answered by 13 days ago

Hello @NortonHDD, I realized that although gameProessedEvent is a parameter of your function, you don't actually check if the event is game processed or not.

Try this:

local function onKeyPressed(inputObject, gameProcessEvent)
    if not (gameProcessEvent) then
        if inputObject.KeyCode == Enum.KeyCode.E then
            print("E")
        end
    end
end

Hope this helps :D

0
If the InputBegan Event was processed by the game's core-scripts, to be exact in its definition. Ziffixture 6785 — 13d

Answer this question