Change text color using a string

for example

changeTextColor(text,color)

changeTextColor(“Hello”, “255,255,255”)

How do I do this?

local textObject = script.Parent

local function changeTextColor(object, text, color)
	object.Text = text
	object.TextColor = color
end

changeTextColor(textObject, "Hello", Color3.new(1, 1, 1))

Assuming the string passed is always 3 number values, you can use following function:

function changeTextColor(guiElement, text, color)
    local r, g, b = color:gsub(" ", ""):match("(%d+),(%d+),(%d+)")
    guiElement.TextColor3 = Color3.fromRGB(tonumber(r), tonumber(g), tonumber(b))
    guiElement.Text = text
end

This would convert strings like "255, 255, 255" to Color3.fromRGB(255, 255, 255)