function Color(r,g,b) if not r then r = 0 end if not g then g = 0 end if not b then b = 0 end local r,g,b = tostring(r),tostring(g),tostring(b) while string.len(r) < 3 do r = "0"..r end while string.len(g) < 3 do g = "0"..g end while string.len(b) < 3 do b = "0"..b end if string.len(r) == 3 and string.len(g) == 3 and string.len(b) == 3 then return "\169"..r..g..b end return "\169255255255"end

btw: The "local"-statement is misleading/useless. r, g & b are already local variables because they are passed in as function parameters. Therefore you can remove the "local"-statement (in more strict languages keeping it there would lead to an error).

The second return statement is never reached because you've made sure that r, g, and b are length 3. So theres no need for it.

Code:

1

local r,g,b = tostring(r),tostring(g),tostring(b)

As DC said this is redundant. And I'd like to point out that there is no need to use tostring here, the numbers will be automatically coerced into strings as needed.

Code:

123456

while string.len(r) < 3 do r = "0"..r end while string.len(g) < 3 do g = "0"..g end while string.len(b) < 3 do b = "0"..b end if string.len(r) == 3 and string.len(g) == 3 and string.len(b) == 3 then return "\169"..r..g..b end