Focus to custom chat on keyboard button press

,
  1. What do you want to achieve? Keep it simple and clear!
    I want to make a custom chat system.

  2. What is the issue? Include screenshots / videos if possible!
    I want the player to focus the textbox (that is connected to textchatservice) when he presses a keyboard button

  3. What solutions have you tried so far?
    This is my current script but I can’t force the player to focus on a textbox reserved to textchatservice.

game.TextChatService.ChatInputBarConfiguration.TextBox = script.Parent

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == TextChatSerice.ChatInputBarConfiguration.KeyboardKeyCode then
		script.Parent:CaptureFocus()
	end
end)

Another question:
How do I detect if the player has the chat bar opened? By opened I mean this
image

I have something like this for a command bar, I believe it’s a property on the textbox

I think it’s this: ChatInputBarConfiguration | Documentation - Roblox Creator Hub.

Here’s code for it:

local TextChatService = game:GetService("TextChatService")

if TextChatService.ChatInputBarConfiguration.IsFocused then
	print("player is focused on the chat bar")
end

Note that:

  • TextChatService.ChatInputBarConfiguration.IsFocused is ReadOnly & is a Bool. This means you can’t set it yourself and use it as a comparison, like the above code.
  • This is a local script
  • Roblox also provides a code example in the docs using the ChangedSignal function, which might better suit another use case.
2 Likes

That’s not what I meant by opened. I want to check if the chat is open, not focused.

Open:
image

Closed:
image

2 Likes

Ah, then I think this might be it:

local a = game:GetService("StarterGui"):GetCore("ChatActive")

StarterGui | Documentation - Roblox Creator Hub:

it return a boolean

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.