Get Text In Chat Input Bar (or replicate it?)

Hey Developers. Is there any way to get the Text within the chat input bar? I was wondering if there is a way to get this information, and I looked for a little bit and couldn’t find anything.

This is what I mean:

image

Any help is much appreciated!

1 Like

Yes! You actually can using Player.Chatted:Connect(). If you want the text the player is typing when he has not sent the message then that would be hard as the new chat system is not relative to the startergui but the coregui.

1 Like

Well so thats What I am wondering. What I am trying to is make a Script that Will get this information, and apply the roblox filter to it, and change the color of the text if it will get filtered. (This is very simplified, as There is a whole bunch of Rate limits applied and Wait times, and It doesn’t filter the text, rather change the color of the bar according to how it thinks it going to be filtered).

Now I have a system, but it isn’t really reliable. Which builds a “Cloned” string of what your trying to type.

local MimicMessage = ""
game:GetService("UserInputService").InputBegan:Connect(function(InputObject : InputObject)
	if game.TextChatService.ChatInputBarConfiguration.IsFocused == true then 
		if InputObject.KeyCode ~= Enum.KeyCode.Unknown then

			if game:GetService("UserInputService"):GetStringForKeyCode(InputObject.KeyCode) ~= " " and game:GetService("UserInputService"):GetStringForKeyCode(InputObject.KeyCode) ~= "" and game:GetService("UserInputService"):GetStringForKeyCode(InputObject.KeyCode) ~= nil or InputObject.KeyCode == Enum.KeyCode.Space then
				MimicMessage = MimicMessage..game:GetService("UserInputService"):GetStringForKeyCode(InputObject.KeyCode)
            elseif InputObject.KeyCode == Enum.KeyCode.Backspace then
			    MimicMessage = MimicMessage:gsub(".?$","");
		     end
	    end
	end
end)

Which is why I’m wondering if I can just… Somehow grab this information… for the most accuracy

What I mean when My system isn't reliable

It clones your input but there is many bugs. Which if this is truely impossible, then I will need to figure these out. Main Bugs include:

  • When you “Hold” a Key, the Input detects One character, but in the chat bar you could be adding more by holding this key. (this also includes holding backspace to delete characters)

  • Keys like :“$” and “@” and “%” etc. are returned as 4, 2, and 5 by using :GetStringForKeyCode()

Hmm. Okay wait a moment ill find a way.

1 Like

Okay… I am back with a bad and good news. Bad news is, I can’t access the chat system. Good new is, I found a way but that requires access to chat system… as well…

2 Likes

So…? I Know that the Legacy Chat system had methods of customization that are different then the Modern day TextChatService (The one I’m using)… I can “View” the chat system in CoreGui, but there is no access to Via, editing them or View their scripts

How do you see core gui in studio?

Nope. There is not. What you can do is well use the old one.

Studio settings

Go to: File -> Studio Settings -> Scroll down till you see
image
Then enable it.

Alright I have an idea.

local TCS = game:GetService("TextChatService")
local CIBC = TCS.ChatInputBarConfiguration
local textstring = ""
local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(i,gpe)
	if CIBC.IsFocused then
		
		if i.KeyCode == Enum.KeyCode.Backspace then
			textstring = textstring:gsub(".?$","");
		else
			textstring ..= uis:GetStringForKeyCode(i.KeyCode)
		end
		print(textstring)
	end
end)

As you see thats my code representation of yours. The idea is that you can see if Shift of CapsLock is on and then depending on that edit the textstring? Would that work?

I can, but I really don’t want too as A. You script that system a tad differently, Meaning I’ma need to rescript most of my script messing with TextChatService. And B. That ChatService is deprecated and can be removed off of roblox any day. (Also just personal opinion, but I like the Modern one a little more).

If I can’t truely Grab this information, then I guess how can I replicat such a system above, but fix my issues…

Possibly Yes. For my usage, It doesn’t matter if it’s cap locks or not, However the Character itself matters most for me (Ex: I don’t care about “q” and “Q”. But I care about “1” and “!”). Only question is well How can I provide such a translation as :GetStringForKeyCode() will return the key typed regardless of the actual input.

So what you can do is make a table that being:

local numstospecial = {
[1] = "!",
[2] = "@",
[3] = "#",
[4] = "$",
[5] = "%",
[6] = "^",
[7] = "&",
[8] = "*",
[9] = "(",
[0] = ")",
}
1 Like

That seemed to work! Thanks… I still am having one more issue…

And this one I have no idea how to address it

1 Like

Ah yea… for that… uhh… You can see if the keys being held using input began ended etc? I suppose? I also found a way to get the text from inputbox directly but stupid roblox prevented it for happening.

local UIS = game:GetService("UserInputService")
local TCS = game:GetService("TextChatService")
local CIBC = TCS.ChatInputBarConfiguration

CIBC:GetPropertyChangedSignal("IsFocused"):Connect(function()
	local tb = UIS:GetFocusedTextBox()
	print(tb)
end)

I found this topic?

I can, but the timing is key… as you see when I hold down the “e” key It adds one character, waits a small amount and then add one every X second

Also as a Side note, what I am trying to achieve I think doesn’t break ToS? That kinda inserted into my Mind, after reading posts about it. I’m not trying to change the text rather get it, which the Docs does mention that I can’t change the text… , does it doesn’t say anything about reading it which I think I’m good?


" For security, some limitations are imposed on the TextBox when it is promoted to ChatInputBarConfiguration.TextBox. Lua code will not be able to:


Anyways that was a little side note but I think what I’m doing is hopefully okay…

No your not breaking the Roblox TOS at all. I do get it your trying to read it but as roblox put their new chat system in the CoreGUI therefore its hard to even acces it! Let alone read it. Best thing would be to either scratch the idea of make a chat of your own OR use the roblox default chat. Though one thing you can do is as it says you can “assign your own textbox” why not do that? Copy the roblox chat, edit it then boom!

1 Like

I can. I have been preventing trying to make one. I’ll see what I can do and mess with timings bit and see! For now I’m go, but I’ll see if I can find a solution later / tomorrow.