Attempt to index string with TextColor3

Hi! I have this script that converts a stringvalue like “0, 0, 0” to a value that color3 will use. It works when I change the color of the player’s nametag but it doesn’t work on a normal gui textlabel for some reason. Can you help me?

local function colorFromString(colorStr: string): Color3
	local components = {}
	for component in colorStr:gmatch("[^,]+") do
		table.insert(components, tonumber(component))
	end
	print("ColorFromString input:", colorStr, "output", table.unpack(components))
	return Color3.fromRGB(table.unpack(components))
end
local currentlySelected;
function updateShop ()
	for i, child in pairs(shopFrame.Style:GetChildren()) do
		if child:IsA("ImageLabel") then child:Destroy() end
	end


	local ownedTrails = ownedTrailsFolder:GetChildren()
	local shopTrails = itemsFolder:GetChildren()

	table.sort(shopTrails, function(a, b)
		return a.Price.Value < b.Price.Value 
	end)

	for i, style in pairs(itemsFolder:GetChildren()) do
		local name = style.Name 
		local price = style.Price.Value
		local desc = style.ItemDescription.Value
		

		local itemSelection = script.Item:Clone()

		itemSelection.Parent = itemScroller
		itemSelection.Name.TextColor3 = colorFromString(style.MainColor.Value)
		itemSelection.Name.TextStrokeColor3 = colorFromString(style.Secondary.Value)
		itemSelection.Title.TextColor3 = colorFromString(style.SecondColor.Value)
		itemSelection.Title.TextStrokeColor3 = colorFromString(style.Secondary.Value)
		itemSelection.SelectButton.MouseButton1Click:Connect(function()
			currentlySelected = style
			itemPreview.PreviewImage.Name.Visible = true
			itemPreview.PreviewImage.Title.Visible = true
			script.Parent.Parent.ItemPreview.Visible = true
			itemPreview.PreviewImage.TextLabel.Visible = false
			itemPreview.Title.Text = name
			itemPreview.Styles.Text = "Buy for " .. price
			itemPreview.Desc.Text = desc
			itemPreview.PreviewImage.Name.TextColor3 = colorFromString(style.MainColor.Value)
			itemPreview.PreviewImage.Name.TextStrokeColor3 = colorFromString(style.Secondary.Value)
			itemPreview.PreviewImage.Title.TextColor3 = colorFromString(style.SecondColor.Value)
			itemPreview.PreviewImage.Title.TextStrokeColor3 = colorFromString(style.Secondary.Value)
			itemPreview.Visible = true
			if player.OwnedStyles:FindFirstChild(style.Name) then
				itemPreview.Styles.Text = "Already Bought"
			end

		end)
	end
end

Thanks!

It is returning Color3.fromRGB({0, 0, 0}) not Color3.fromRGB(0, 0, 0), possibly.

temPreview.PreviewImage.Name

The script believes this is a reference to the ‘Name’ property, not a child instance named ‘Name’, change the child’s name.

I use 0, 0, 0 in the value, not (0, 0, 0)

@Forummer hit the nail on the head.

Even if you have a child instance named ‘Name’, the script will assume you mean the Name property, unless you use a ‘child grabbing’ function such as :FindFirstChild().

Lines that will generally encounter this issue:

itemSelection.Name.TextColor3 = colorFromString(style.MainColor.Value)
itemSelection.Name.TextStrokeColor3 = colorFromString(style.Secondary.Value)
itemPreview.PreviewImage.Name.TextColor3 = colorFromString(style.MainColor.Value)

Along with the others.