So, basically I made a GUI that pops up whenever you press "B", but the issue I'm having is that whenever players are typing in chat the GUI pops up and gets in the way of everything. If someone could please tell me how to fix this it'd really be appreciated. Here is the code to pop up the GUI.
(Local Script)
local textBox = script.Parent local originalColor = textBox.BackgroundColor3 local Players = game:GetService("Players") local player = Players.LocalPlayer local UserInputService = game:GetService("UserInputService") local screenGUI = script.Parent.Parent.Parent if player:GetRankInGroup(5365673) >= 250 then print("literally nothing") else script.Parent.Parent.Parent:Destroy() end UserInputService.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.B then if player:GetRankInGroup(5365673) >= 250 then if screenGUI.Enabled == false then screenGUI.Enabled = true textBox.Active = true textBox.TextEditable = true script.Parent.Parent.TextButton.Visible = true end end end end) local function onFocusLost(enterPressed) if enterPressed then local plrText = textBox.Text print("The player typed: " .. textBox.Text) -- Color the text box according to the typed color local brickColor = BrickColor.new(textBox.Text) textBox.BackgroundColor3 = brickColor.Color game:GetService("ReplicatedStorage").Announce:FireServer(plrText,player) wait(1) textBox.BackgroundColor3 = originalColor end end textBox.FocusLost:Connect(onFocusLost)
You can achieve this by the GameProcessed
Boolean parameter returned by UserInputService’s InputBegan
signal. This parameter defines whether one of ROBLOX’s core services is using input systems. You can debounce your code with GameProcessed
to ignore your input events if so.
local UserInputService = game:GetService("UserInputService") UserInoutService.InputBegan:Connect(function(Input, GameProcessed) if (GameProcessed) then return end if (Input.KeyCode == Enum.KeyCode.B) then --// Code end end)