#Issues with TextChatService

1 messages · Page 1 of 1 (latest)

upbeat basin
#
--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)
frozen shell
#

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

upbeat basin
#

this is SENDING a message from the server

#

no chats are added until i add it myself

frozen shell
#

oh

upbeat basin
#

this is just the client side

#

of actually sending it

frozen shell
#

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

upbeat basin
#

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

frozen shell
upbeat basin
#
TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(`<font color='#00f00'>{" .. rune .. "}</font>`)
#

this is what it expects

pale cave
upbeat basin
#

thats why i included asking for that

pale cave
#

different line
I don't know what you mean by this, can you explain exactly what you desired result is?

upbeat basin
#

the first statement doesnt even send a message yet

#

thats the gradient one

upbeat basin
#

i specifically check if its a gradient so i can handle it differently

pale cave
upbeat basin
#

ty

#

yk any of the other issues?

pale cave
#

:ToHex() seems to output the hex color without a pound symbol

upbeat basin
#

TY

#

I LOVE YOU

#

TY

#

TY

pale cave
#

yw 💜

upbeat basin
#

I KNEW ITD BE DUMB

#

i had that issue like 2 days ago

#

with chat tags

#

😭

pale cave
#

Also your string interpolation looks kinda wrong, your using both " and `
this is probably what you want

`<font color='#{color:ToHex()}'>{rune}</font>`
upbeat basin
#

youre amazing 🙏

#

now how do i set a gradient to a chat message?

pale cave
#

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)