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!