--throwing some lines in so this makes sense
events.chatMessage.OnClientEvent:Connect(function(runeName, rune, clampedRarity)
local color = nil
local runeGui = script.Parent.Parent.runeGui[runeName].ScrollingFrame.runeFrame[rune]
if runeGui:GetAttribute("gradient") then
color = ColorSequence.new(runeGui.UIGradient.Color)
--How can i apply a gradient?
else
color = runeGui.TextButton.TextColor3
--this sends in an HTML format, how can i make it actually read the data and not just send it
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("`<font color='" .. color:ToHex() .. "'>{" .. rune .. "}</font>`")
end
end)
#Issues with TextChatService
1 messages · Page 1 of 1 (latest)
you may want to start by using TextChatService.OnChatWindowAdded and TextChatService.OnIncomingMessage
and I don't think you aren't formatting it I don't think, at least not how I normally do it
oh
then you could prolly like
local gradient = Instance.new("UIGradient") gradient.Color = ColorSequence.new{ ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 150, 50)), ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 50, 150)), } then set the Parent to where ur text properties
bro 💀
rich text aint the issue it would allow text if i changed how i was puting my hex color, but id like it to be a bit more efficient and not need to MANUALLY TYPE 100 COLORS LOL
oops
accidentally went into caps halfway
also with applying gradients, i already set the color i just need to apply it, i dont know hwo to appy to a text color in the textchat
bruh I'm trying, I actually don't know the problem I'm just reading documentation
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(`<font color='#00f00'>{" .. rune .. "}</font>`)
this is what it expects
Color sequences don't have a :ToHex() method, rich text also doesn't have any sort of built in gradient support. My intuition says you should manually interpolate the color gradient and add a font color tag to every character but TextChatService might have support for adding UIGradient (idk)
the gradient will have a different line
thats why i included asking for that
different line
I don't know what you mean by this, can you explain exactly what you desired result is?
see how its an else?
the first statement doesnt even send a message yet
thats the gradient one
i specifically check if its a gradient so i can handle it differently
The Color property is already a ColorSequence, you can just do color = runeGui.UIGradient.Color
https://create.roblox.com/docs/reference/engine/classes/UIGradient#Color
:ToHex() seems to output the hex color without a pound symbol
LOL
TY
I LOVE YOU
TY
TY
yw 💜
Also your string interpolation looks kinda wrong, your using both " and `
this is probably what you want
`<font color='#{color:ToHex()}'>{rune}</font>`
My thought is you could loop through every character of the message and give it its own font tag with a color based on the character's position in the string.
works in a text label pretty well
-- Stolen from roblox docs https://create.roblox.com/docs/reference/engine/datatypes/ColorSequence
local function evalColorSequence(sequence: ColorSequence, time: number)
-- If time is 0 or 1, return the first or last value respectively
if time == 0 then
return sequence.Keypoints[1].Value
elseif time == 1 then
return sequence.Keypoints[#sequence.Keypoints].Value
end
-- Otherwise, step through each sequential pair of keypoints
for i = 1, #sequence.Keypoints - 1 do
local thisKeypoint = sequence.Keypoints[i]
local nextKeypoint = sequence.Keypoints[i + 1]
if time >= thisKeypoint.Time and time < nextKeypoint.Time then
-- Calculate how far alpha lies between the points
local alpha = (time - thisKeypoint.Time) / (nextKeypoint.Time - thisKeypoint.Time)
-- Evaluate the real value between the points using alpha
return Color3.new(
(nextKeypoint.Value.R - thisKeypoint.Value.R) * alpha + thisKeypoint.Value.R,
(nextKeypoint.Value.G - thisKeypoint.Value.G) * alpha + thisKeypoint.Value.G,
(nextKeypoint.Value.B - thisKeypoint.Value.B) * alpha + thisKeypoint.Value.B
)
end
end
end
local rune = "Hello, World"
local color = ColorSequence.new(Color3.new(1, 0, 0), Color3.new(0, 1, 0))
local str_len = #rune
local str_out = ""
for i = 1, str_len do
local char = rune:sub(i, i)
local delta = (i-1) / (str_len-1)
local interpolated_color = evalColorSequence(color, delta)
str_out ..= `<font color='#{interpolated_color:ToHex()}'>{char}</font>`
end
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(str_out)