Well correct “%d+” matches one or more occurences of numeric digits. But “%d+” doesn’t take float numbers into account and not that he uses or will use one, but your code returns an invalid result if he does.
Tested code
local function colorFromString1(colorStr: string): Color3
local components = {}
for component in string.gmatch(colorStr, "[^,]+") do
table.insert(components, tonumber(component))
end
--print("ColorFromString input:", colorStr, "output", table.unpack(components))
return Color3.fromRGB(table.unpack(components))
end
local function colorFromString2(colorStr: string): Color3
local components = {}
for component in string.gmatch(colorStr, "%d+") do
table.insert(components, tonumber(component))
end
--print("ColorFromString input:", colorStr, "output", table.unpack(components))
return Color3.fromRGB(table.unpack(components))
end
local colorString = "255, 83.75, 20.1"
print("Expected Color ->", Color3.fromRGB(255, 83.75, 20.1))
print("match([^,]+) --->", colorFromString1(colorString))
print("match(%d+) ----->", colorFromString2(colorString))
Yes, but there’s no problem with leading/trailing whitespaces in the tonumber, so why make an ugly pattern, the one above is cleaner and does the job. If whitespace is a problem just add a space in the pattern like this “[^, ]+” way cleaner.
But thanks for the sujestion.