So I am using richtext to color a players name in chat, and I want to put the player’s name into a string.
local function rgb255RichText(color3)
local R = (color3.R * 255)
local G = (color3.G * 255)
local B = (color3.B * 255)
return string.format("rgb(%d, %d, %d)", R, G, B)
end
function createtext(stri,plr)
local c = Text:Clone()
local color = rgb255RichText(Color3.fromRGB(0, 55, 235))
local name = color
c.Text = [[<font color="]] .. color .. [[">[ "PLAYER NAME HERE" ]</font>]] .. " " .. stri
c.Parent = goal
end
Can someone tell me how I would put Player.Name where it says “PLAYER NAME HERE”?
The Color3 data-type has a ToHex method, which you can use to set the font color:
-- There's no longer a need to use the rgb255RichText function
function createtext(stri, plr)
local color = Color3.fromRGB(0, 55, 235) -- Create a Color3 value using the RGB values of your choosing
local c = Text:Clone()
c.Text = `<font color="#{color:ToHex()}">[{plr.Name}]:</font> {stri}` -- Convert the color to hex, and format the text
c.Parent = goal
end