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

GUI's come up while chatting, unsure how to disable?

Asked by 9 years ago

Alright so I have some keys set up so when you press them it brings up the GUI. Well problem is they happen to come up while chatting as well. So if I want to type "Hey" it'll bring up my Help GUI because I set H to do that, here is the code, is there a way to get rid of this?

local player = script.Parent.Parent
local guis = game.ReplicatedStorage.PopUps

function onKeyPress(inputObject, gameProccessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.H then
        local help = guis.Help:Clone()
        help.Parent = player.PlayerGui
        player.PlayerGui.PlayerAudio.Pullup:Play()
        end
    end
end

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

function onKeyPress(inputObject, gameProccessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Q then
        local options = guis.Options:Clone()
        options.Parent = player.PlayerGui
        player.PlayerGui.PlayerAudio.Pullup:Play()
    end
end

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


1 answer

Log in to vote
0
Answered by 9 years ago

There's a second argument of InputBegan, gameProceessedEvent, it's true when you're chatting and false when you aren't. Just put an if statement before you check if it was a keypressed to avoid it firing when chatting

function onKeyPress(inputObject, gameProccessedEvent)
    if not gameProccessedEvent then
        print'key was pressed but not while chatting c:'
    end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

0
Thanks! :D CrispyBrix 113 — 9y
Ad

Answer this question