Hi,
I want to know if it is possible to make rainbow chat text in the new chat service, TextChatService.
In the old text service, it was very easy to do but I don’t know if it’s possible on the new service since I never seen anyone do it.
Thanks for reading.
2 Likes
Here’s an example of what I mean:
With the release of the RichText feature, this can be done now with RichText, string patterns, and a table. I actually wrote a script for this just recently.
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local chat = playerGui:WaitForChild("Chat")
local frame = chat:WaitForChild("Frame")
local chatChannelParentFrame = frame:WaitForChild("ChatChannelParentFrame")
local frameMessageLogDisplay = chatChannelParentFrame:WaitForChild("Frame_MessageLogDisplay")
local scroller = frameMessageLogDisplay:WaitForChild("Scroller")
function rainbowText(textLabel)
if textLabel.ClassName == "TextLabel" then
textLabel.RichText = true
local s = textLabel.Text
local frequency = 1 -- determines how quickly it repeats
local totalCharacters = 0
local strings = {}
for character in string.gmatch(s, ".") do
if string.match(character, "%s") then
table.insert(strings, character)
else
totalCharacters += 1
table.insert(strings, '<font color="rgb(0, 0, 0)">')
table.insert(strings, character..'</font>')
end
end
while task.wait() do
local str = ""
local counter = totalCharacters
for _, sub in ipairs(strings) do
if string.match(sub, "%a+%b()") then
counter -= 1
local color = Color3.fromHSV(-math.atan(math.tan((os.clock() + counter/math.pi)/frequency))/math.pi + 0.5, 1, 1)
sub = string.gsub(sub, "%a+%b()", "rgb("..math.floor(color.R * 255)..", "..math.floor(color.G * 255)..", "..math.floor(color.B * 255)..")")
end
str ..= sub
end
textLabel.Text = str
end
end
end
for _, textLabel in pairs(scroller:GetDescendants()) do
rainbowText(textLabel)
end
scroller.DescendantAdded:Connect(function(textLabel)
rainbowText(textLabel)
end)
This should be the results:
//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/a/a/9/aa9828fb9eb91fb61e66c43c36a4927a8b42ee87.mp4
I hope this helps!
WARNING: Using RichText for a chat system will prevent the chat from being filtered. I recommend using this method for in-game text only.
It is not possible in robloxs new textchatservice (to my knowledge) because robloxs actual gui for textchatservice is in coregui and using textchatserviceproperties doesnt work after its initally fused with the textchatmessage and changing textchatmessage doesnt work at all.
I have managed to partially replicate it but it was a little hacky
24redii
(24redii)
December 13, 2023, 10:21pm
#5
why are you gatekeeping the code
Sorry, I changed the property for textcolor3 in textchatservice’s ChatWindowConfiguration to the RGB every heartbeat but if they didnt have the rgb enabled, I use overridemessageproperties on the incomingmessage callback to override that and make it the default text color. There’s probably a better way to do it and I might be recalling it incorrectly but it’s what worked for me.
2 Likes
24redii
(24redii)
December 18, 2023, 9:49pm
#7
thanks! i’ll try that and see if it works!
24redii
(24redii)
March 25, 2024, 8:12pm
#8
bruh its been 3 months and i still can’t do this, it changes the chat bubble to white and also the heartbeat lags the game
EDIT: I solved it now it’s ok
1 Like