Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Key opens when chatting. Could anyone help me out?

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)

1 comment

0

welp i have the same problem xd

1 answer

✓ Accepted answer

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)

1 comment

0

Thanks, it worked!

This discussion is preserved as it was. New answers, comments, and votes are closed.