This is my datastores script I use for various games, I want to do a customizable character system where you can change your colour schemes but the output keeps saying it can't save the color3 value and I figured you can't save regular C3 values so I wanted to see how I could go about that in the context of this script
I need the C3 values specifically since the colour-changeable parts of your character take their colours from a color3 value in the player and the color3 value has a script that changes the color3 value in the datastores (playerstats folder) when it senses a change in the color3 value in the player and when a player respawns it checks the color3 value in the player and updates itself to that one so it has a 2-way communication system, the only problem is that I can't save the color3 value in datastores
local datastore = game:GetService("DataStoreService") local ds2 = datastore:GetDataStore("LightSaveSystem") local ds3 = datastore:GetDataStore("PrimarySaveSystem") local ds4 = datastore:GetDataStore("SecondarySaveSystem") local ds5 = datastore:GetDataStore("MasterSaveSystem") game.Players.PlayerAdded:connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "playerstats" local Light = Instance.new("Color3Value", folder) Light.Name = "Light" local Primary = Instance.new("Color3Value", folder) Primary.Name = "Primary" local Secondary = Instance.new("Color3Value", folder) Secondary.Name = "Secondary" local Master = Instance.new("BoolValue", folder) Master.Name = "Master" Light.Value = ds2:GetAsync(plr.UserId) or Color3.new(0/255, 255/255, 0/255) ds2:SetAsync(plr.UserId, Light.Value) Primary.Value = ds3:GetAsync(plr.UserId) or Color3.new(0/255,0/255,0/255) ds3:SetAsync(plr.UserId, Primary.Value) Secondary.Value = ds4:GetAsync(plr.UserId) or Color3.new(255/255,255/255,255/255) ds4:SetAsync(plr.UserId, Secondary.Value) Master.Value = ds5:GetAsync(plr.UserId) or false ds5:SetAsync(plr.UserId, Master.Value) Light.Changed:connect(function() ds2:SetAsync(plr.UserId, Light.Value) end) Primary.Changed:connect(function() ds3:SetAsync(plr.UserId, Primary.Value) end) Secondary.Changed:connect(function() ds4:SetAsync(plr.UserId, Secondary.Value) end) Master.Changed:connect(function() ds5:SetAsync(plr.UserId, Master.Value) end) end)
I would do what's called a serialization
.
Essentially, store a table
with the RGB
values of the Color3.
ds:SetAsync(plr.UserId, { R = color.R, B = color.B, G = color.G })
When you want to access, it, you have to deserialize
it.
local serializedColor = ds:GetAsync(plr.UserId) local color = Color3.new(serializedColor.R, serializedColor.B, serializedColor.G)