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

Key opens when chatting. Could anyone help me out?

Asked by 3 years 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 1091 — 3y

1 answer

Log in to vote
3
Answered by 3 years ago
Edited 3 years 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 — 3y
Ad

Answer this question