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
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 = Color3.new(retrievedTable.eyeColors.R,retrievedTable.eyeColors.G,retrievedTable.eyeColors.B)
Color3ValueObject.Value = newColor3
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.
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])
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.