Answered by
6 years ago Edited 4 years ago
Color3 values cannot be saved via datastore in its original format. In order to get around this problem, we can store each variable of the Color3 value into a table. Once we've done this, we can save this value using JSONEncode that allows us to convert the table into a string in a format where DataStore can save it (JSON: http://wiki.roblox.com/index.php/JSON. Use this as an example.
1 | local NewTable = { PARTNAME.Color.r,PARTNAME.Color.g,PARTNAME.b } |
2 | local JSONTable = game:GetService( "HttpService" ):JSONEncode(NewTable) |
3 | PrimaryDataStore:SetAsync(id, JSONTable) |
5 | local ColorTable = PrimaryDataStore:GetAsync(id) |
6 | local DecodedTable = game:GetService( "HttpService" ):JSONDecode(Color 3 Table) |
7 | local ColorValue = Color 3. new(DecodedTable [ 1 ] ,DecodedTable [ 2 ] ,DecodedTable [ 3 ] ) |