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)

1 comment
You can use ContextActionService.