Basically, I’m using a custom textbox for chat, and I set the playergui to use that textbox, and it works! The problem is that even though KeyboardKeyCode is setup and enabled, it won’t detect when I press /, and the textbox doesn’t focus.
tl;dr: textbox doesnt focus when pressing / like in roblox chat
I tried using :CaptureFocus() but I got an error saying im trying to do it on a reserved textbox for chat, and I couldn’t.
I don’t know if this is what you are trying to do. But I just used UserInputService.InputBegan and it detects Slash. Make sure you don’t return if gameProcessedEvent as lots of scripts do.
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.Slash then
print("Slash pressed")
end
end)
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local screenGui = playerGui:WaitForChild("ScreenGui")
local textBox = screenGui:WaitForChild("TextBox")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.Slash then
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
print("Slash pressed")
if textBox.PlaceholderText == " " then
print("toggled off")
textBox.Text = ""
textBox.PlaceholderText = "To chat, click here or press / key"
textBox:ReleaseFocus()
else
print("toggled on")
textBox.PlaceholderText = " "
task.spawn(function()
for i = 0, 10 do
textBox.Text = ""
task.wait()
end
end)
textBox:CaptureFocus()
textBox.FocusLost:Once(function()
textBox.Text = ""
textBox.PlaceholderText = "To chat, click here or press / key"
end)
end
end
end)
Is that a fully custom chat system that you scripted, or is the Textbox configured to ChatInputBarConfiguration.Textbox and using Roblox’s chat system?
It’s a regular TextBox, if you want to create a custom chat system. Why don’t you not use the ChatInput stuff and just do it manually like with RemoteEvents
then it would be a huge vulnerability for players as you could send any message on their behalf and get them banned. The solution to this is to not use ChatInputBarConfiguration as it’s .TextBox property has not been fully implemented yet and create your own chat system using remote events and TextChannel:SendAsync()