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

How to tell if a player is chatting with UserInputService?

Asked by 5 years ago

The script works fine, I just dont know how to keep it from opening when you press e while chatting.

uis.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.E then
    if gui.Enabled == false then
    gui.Enabled = true
else
    gui.Enabled = false
        end
    end
end)

1 answer

Log in to vote
1
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

InputBegan, along with InputEnded, returns another value that can be used to tell when the player is chatting or doing another task with things such as the menu or chatting.

This value is called gameProcessedEvent Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, gameProcessedEvent would be true. This is also true for input events connected via ContextActionService

uis.InputBegan:Connect(function(key,g)
    if g then return end

    if key.KeyCode == Enum.KeyCode.E then
    if gui.Enabled == false then
    gui.Enabled = true
else
    gui.Enabled = false
        end
    end
end)

Ad

Answer this question