it’s a service just called “chat”. it seems to not be visible by default anymore, so you can enable this studio setting to see it if that’s the case
thank you! I will give this a look
This looks really awesome, though I have a few questions + an issue I encountered;
As for the questions, are you planning on adding DisplayName support? From what I can see, the chat doesn’t show display names, only usernames (except for the friend join messages). I also noticed that the ‘Roblox automatically translates chat messages’ message that appears with the default TextChatService is also appearing when I first join the server on PC (doesn’t happen on mobile), is there a way to disable that?
And as for the bug (i assume), in mobile, when trying to send a message, it just adds a newline instead of sending the message.
I did notice that this bug apparently also happens to me in other games that use the legacy chat service, so maybe it’s a Roblox thing? I’m just kinda confused abt that
Good job! It works great. Will you add DisplayName support?
I was working on a thing exactly like this, but yours is scripted way better.
Also, will you work on making the old chat tags work too?
Seems your working on it, or maybe I messed something up.
I want to know if that’s something you want to do because I got it working on my one
Yeah, I can add support for display names! That should only take a minute or two.
The “Roblox automatically translates chat messages” message is a system message that Roblox automatically sends to the player as soon as they join. If you want to override it, you’ll have to manually add in an extra check for that message specifically.
The mobile bug I wasn’t able to replicate. I’m not sure what’s going on there, because I’m not doing anything particularly fancy with the TextBox there.
Chat tags should be fully functional already.
Here’s a code sample you can throw into a script in ServerScriptService if you need to test:
local ServerScriptService = game:GetService("ServerScriptService")
local Players = game:GetService("Players")
local SpeakerProperties = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("SpeakerProperties"))
Players.PlayerAdded:Connect(function(player)
-- Adds a yellow tag named "Tag" with priority 3 to all players
SpeakerProperties.addTag(player, "Tag", Color3.new(1, 1, 0), 3)
end)
Hello! Thanks for the reply.
Is there any chance you would modify it to work with how you would used to make chat tags on Legacy Chat?
I could modify it myself to do it but to be honest I’m just wondering if you would be interested in doing it, as it might be useful for others.
fortunately i’ve actually already dealt with something similar to this. for some reason the text on these system messages is always that light gray color, and i wanted it to be black for my personal modifications to the system. the check i made for it can easily be modified to delete this message instead
just replace lines 205-210 of the “Message” script with
if sourceText ~= nil then
-- Add spacing for source text
messageLabel.Text = `<font transparency = "1"><stroke transparency="1">{sourceText}</stroke></font> {messageText}`
else
if string.sub(messageText,1,22) == [[<font color="#d4d4d4">]] and translationMessageRemoved == false then
translationMessageRemoved = true
return
end
messageLabel.Text = messageText
end
and create a “translationMessageRemoved” variable set to false before that Message.create function (around line 26)
i threw this version of it together pretty hastily so it will throw a few errors, but from the looks of it, it won’t actually disrupt anything. so you can add some stuff to the erroring scripts to clean it up, or just ignore it
edit: i found out how to remove the error it was pretty easy
just add
if frame == nil then return end
between lines 65 and 66 of the ChatChannel script that the Message script is parented to
if you want to additionally remove all system messages like that (such as the one for when you change teams) you can just remove any mention of translationMessageRemoved from that block of code and it’ll stop those too
again, not a perfect solution, but this is at least the route to go for if you want to detect these kinds of messages
I’ve been trying to work a bit on making this a bit more accurate, and I noticed that for some reason the size of the chat frame is different than the original legacy chat when playing ingame (i’m pretty sure it’s the correct size in studio when playtesting though?) for some reason
(The second image is the original Legacy Chat, while the first image is this rewrite)
The chat window is basically larger than normal
(the “You are now privately chatting with […]” is also missing, along with ‘cancelling’ the private message/switch back to the default channel by clicking on the other player’s name in the text box (where it says “[To PlayerName]”) — I tried to fix that part myself but I kinda got stuck on it so I was wondering if u could try to fix that when you have time)
No; it wouldn’t be very practical, because speaker objects don’t exist in this system, which means I’d just be forcing you to jump through an additional hoop for the sake of making the code look the same. I tried to keep the structure and usage as similar as possible without adding unnecessary complexity.
Ran a playtest recently with the GZARP playerbase and caught a handful of bugs, including:
- Players are unable to type in the chat bar on mobile
- Sending RichText symbols (<, >, etc.) shows up as the original escape forms in bubble chat (“<”, “>”, etc.)
- The “w” in “/w” gets registered as a username search for “w”
- Whispering to a player sometimes cuts off their username
- Typing indicator is visible from way too far away
I’ve gotten the easy fixes out of the way and published an updated version, but I still need to do some more testing for mobile devices; they seem to be causing a lot of trouble.
If anyone else can figure out some of the mobile issues before I do, let me know and I’ll publish an updated version.
thats really good! but how do I make it use the new bubble chat and not your own custom one? I am only looking for the design of the chat, not change the bubble chat.
Speaking of the custom chat bubbles the whole text does not fully appear. For example, if you type in a single letter, the chat bubble will appear empty. That was a common thing with the old chat bubbles, But I Manually fixed that problem by increasing the width where it creates the TextLabel.
Actually very good! Only a slight UI difference between the Legacy Chat and your rewrite
I made a few adjustments to more closely match the legacy chat, and also added a few settings to ChatConstants
Could you please elaborate on the changes you have made?
Legacy chat I believe had a bug relating to the sizing. Basically, when opening roblox, the size of the game window is not what it should be (it’s instead somewhat small for a short period of time). Depending on when the chat loads, it registers a size that isn’t the actual size of your screen, and would sometimes wrongly set the chat size has Tablet or Phone
This is how it detects the device type internally
(Settings module)
This is something I have fixed in my forked version of the legacy chat (however, I cannot tell you if the size settings in my forked version are the same as the default ones)
It’s possible that this bug doesn’t occur when in studio, since the game window doesn’t resize when play testing
The default size for Desktop has a scale of 0.3
Added on to the README the changes I made, these specifically (for accuracy to Legacy Chat):
--[[
CHANGES MADE
ChatConstants.RemoveTranslationsEnabledMessage added, defaults to false
ChatConstants.UseCustomCommandsColor added, defaults to false
ChatConstants.ChatWindowLayoutOrder added, defaults to 6
ChatConstants.MessageFrameAutomaticSize added, defaults to Enum.AutomaticSize.Y
ChatConstants.MessageLabelAutomaticSize added, defaults to Enum.AutomaticSize.Y
MessageLog.registerMessageAddedCallback shouldn't error when Message.create returns nil
ChatConstants.DefaultChatWindowSizeScale set to (0.4, 0.33) from (0.4, 0.34)
]]
One thing this forgot is that ChatConstants.WindowResizeable
defaults to false
And I made a mistake (ChatConstants.RemoveTranslationsEnabledMessage
defaults to true
), I’ll fix these with a simple update
I also included a command bar loader to save some time, this is the code (minus the comment which has instructions on using it)
local legacyChatRewrite = workspace["Basic Legacy Chat Rewrite"]
local whatGoesInChat = legacyChatRewrite["PUT ME IN CHAT AND UNGROUP"]
local whatGoesInScriptService = legacyChatRewrite["PUT ME IN SERVERSCRIPTSERVICE AND UNGROUP"]
for _, obj in whatGoesInChat:GetChildren() do
obj:Clone().Parent = game.Chat
end
for _, obj in whatGoesInScriptService:GetChildren() do
obj:Clone().Parent = game.ServerScriptService
end
what command bar did you add?
???
the code snippet he provided above is supposed to be ran using command bar, he didn’t add a command bar to the chat.
This looks great! Mind if I overwrite the current model with your version?
Edit: Noticed this code snippet here where you were trying to override the system message color. This is unfortunately the correct way to do it; I did not set the system message color, Roblox just adds a RichText tag to all system messages to color them grey.
if not ChatConstants.UseCustomCommandsColor then
-- hacky workaround
-- i have no clue where the hell the color is set
-- all i know is the setting for it is disabled and the color shall not be present
scroller.ChildAdded:Connect(function(message)
if not message:IsA("Frame") then
return
end
local label = message:FindFirstChildOfClass("TextLabel")
if string.find(label.Text, '<font color="#d4d4d4">') then
local text = string.gsub(label.Text, '<font color="#d4d4d4">', '')
text = string.gsub(text, '</font>', '', 1)
label.Text = text
end
end)
end
Saezi covered this issue in this thread a little bit ago: