Benchmarking your code took around 630ms on my pc (well laptop).
If I edited your code a bit, it suddenly becomes 370ms:
local function Color3FromHex(str)
if type(str) == "number" then -- in case of hexadecimal numbers, we can do this!
return c3(floor(str / (256^2)), floor(str / 256) % 256, str % 256)
end str = tonumber(str,16)
assert(str, "Input must be a hexadecimal string or number")
return Color3FromHex(str)
end
Well, that leaves out the lots of overloads for making hexadecimal colors. Although I didn’t test the number-case of the function, only the string cases.
Weird, @einsteinK - how’d you do your benchmarking?
local n = 100000
local start = tick()
for i = 1, n do
local c = Color3FromHex(somestring)
end
print((tick() - start) / n)