How do I convert "255 255 255" to r,g,b numbers?

So I’m currently trying to convert the follow RGB numbers “255 255 255” to “255, 255, 255” since that would just make the Color3Value set to 0, 0, 0

I’m making a database color system, and this was my attempt.


That however just returned 0, 0, 0 instead of 255, 255, 255
Basically, I want the commas added after each numbers.
Anything helps, thanks in advance.

1 Like

This should work:

local colors = string.split(colors[1], " ")
EyesColor.Value = Color3.fromRGB(unpack(colors))

it worked however it only did “255,0,0” instead of “255,255,255” is there any ways i could fix that?

Oh, that’s my bad. This should work, assuming that colors is a string with 3 values of course:

local colors = string.split(colors, " ")
EyesColor.Value = Color3.fromRGB(unpack(colors))

Well, colors is actually color3value loaded in a database, that’s why It was called color[1] since there are multiple colors, anyways I tried that but it didn’t work… Sadly

Ah, but if it’s a Color3Value shouldn’t you just be able to access .Value which would return a Color3?

Yeah, however this was my only method since I’m trying to save RGB values.

table.insert(save, {EyesColor.r*255,EyesColor.g*255,EyesColor.b*255})

I had to multiply by 255 to convert it to RGB values. But sadly, it didn’t keep the commas. You think there are any ways on adding commas?

I don’t see why you need the commas, if you have it in rgb order just do Color3.fromRGB(unpack(table)). This should work if the table is like this:


Not wrong I guess :man_shrugging:

This might be because the DataStoreService converts tables to JSON strings to save, and JSON obviously doesn’t accept roblox data types such as CFrames, in your case, Color3 values. What you could do is make a table with each 3 numbers that the value consists of, and then make that a Color3 value. Of course it is a super hacky way of doing it, but I do not know a better way.

-- how your table should look like to save (you can add other things if you need, such as cash, exp, other colors)
local exampleTable = {
	eyeColors = {
		R = Color3ValueObject.Value.R,
		G = Color3ValueObject.Value.G,
		B = Color3ValueObject.Value.B,

-- retrieving and setting the color example

local retrievedTable = datastore:GetAsync(yourKey)

-- constructing a color3 of of these values
local newColor3 =,retrievedTable.eyeColors.G,retrievedTable.eyeColors.B)

Color3ValueObject.Value = newColor3

Hope this helped!

1 Like

what I do is save it as seperate int values

local color = Color3.fromRGB(255,255,255)
EyesColorR.Value = color.R
EyesColorG.Value = color.G
EyesColorB.Value = color.B


I tried doing the way you did it but it says "Attempt to index nil with “R” although it perfectly stored in the database! Just not sure how to get the R, G, B from it.

My table

table.insert(save, {
		eyeColors = {
		R = EyesColor.r*255,
		G = EyesColor.g*255,
		B = EyesColor.b*255

Applying the colors from the database


String.split is what you’ll want to use. Assuming that you know there will always be a space between the color integers string.split will give you a table with 3 color integers for you to use.

local color = "255 255 255" -- just use whatever variable your color string is.
local colorTable = string.split(color, " ")

EyeColor.Value = Color3.fromRGB(colorTable[1], colorTable[2], colorTable[3])

You can read up more about the string.split function and other string functions on the wiki page string | Documentation - Roblox Creator Hub

I think it’s because you’re putting in another table with the eyeColors table

table.insert(save, { -- this curly bracket
		eyeColors = {
		R = EyesColor.Value.R,
		G = EyesColor.Value.G,
		B = EyesColor.Value.B
	}) -- and this one behind the bracket

That would make the eyeColors table be “behind” another one. For that, just put [1] to index that table when creating the Color3 value.


Edit: You’re not putting .Value after the object, you don’t wanna multiply by 255 and also I think you have to capitalize the R,G,B after .Value

Don’t worry, EyeColors was defined aslong with It’s value.

local EyesColor = folder.EyesColor.Value

Also, I thought you needed 2 tables as you mentioned here?

local exampleTable = {
	eyeColors = {
		R = Color3ValueObject.Value.R,
		G = Color3ValueObject.Value.G,
		B = Color3ValueObject.Value.B,

Somehow it still doesn’t work.

Somehow I fixed it from your example code, thanks you so much and everyone else here for the help! I hope anyone else learns out of this.

1 Like