Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
2

Key opens when chatting. Could anyone help me out?

Asked by 2 months ago

Hi, I recently hired a scripter to make me a Gui that opens when I press "B". Now everything works fine but there's just one thing, When I type B for example: "Big" in chat it opens the Gui. I asked him if he could fix the issue but he hasn't replied in 4 weeks. Could anyone please help me out with this?

local inputservice = game:GetService("UserInputService")

inputservice.InputBegan:connect(function(i,g)
    if i.UserInputType == Enum.UserInputType.Keyboard then
        if i.KeyCode == Enum.KeyCode.B then
            game.ReplicatedStorage.OpenBook:FireServer()
        end
        end
end)
0
welp i have the same problem xd Nguyenlegiahung 1070 — 2mo

1 answer

Log in to vote
3
Answered by 2 months ago
Edited 2 months ago

If you don't want it to fire the RemoteEvent when you press B while typing in chat, then you could add this:

local InputService = game:GetService("UserInputService")

InputService.InputBegan:Connect(function(Input, IsTyping)
    if IsTyping then return end
    if Input.UserInputType == Enum.UserInputType.Keyboard then
        if Input.KeyCode == Enum.KeyCode.B then
            game.ReplicatedStorage.OpenBook:FireServer()
        end
    end
end)
0
Thanks, it worked! toompske 12 — 2mo
Ad

Answer this question