I'm trying like crazy to store my character customization data and I don't know what to do now
Error
104: Cannot store Array in DataStore Stack Begin Script 'ServerScriptService.DataStore', Line 83 Stack End 104: Cannot store Array in DataStore Stack Begin Script 'ServerScriptService.DataStore', Line 111 Stack End
Datastore Script
local DataStore = game:GetService("DataStoreService"):GetDataStore("Test11") --CREATES THE PLAYER DATA FOLDER game.Players.PlayerAdded:connect(function(plr) --USER DATA KEY local Key = "O-"..plr.userId --DATA FOLDER local PlrFolder = Instance.new("Folder", plr) PlrFolder.Name = "Data" --CUSTOMIZATION DATA local Character = Instance.new("Folder", PlrFolder) Character.Name = "Character" local Hair = Instance.new("ObjectValue", Character) Hair.Name = "Hair" local HairC = Instance.new("Color3Value", Character) HairC.Name = "HairC" local Hair2 = Instance.new("ObjectValue", Character) Hair2.Name = "Hair2" local Hair2C = Instance.new("Color3Value", Character) Hair2C.Name = "Hair2C" local Shirt = Instance.new("ObjectValue", Character) Shirt.Name = "Shirt" local Pants = Instance.new("ObjectValue", Character) Pants.Name = "Pants" local Accessory = Instance.new("ObjectValue", Character) Accessory.Name = "Accessory" local AccessoryC = Instance.new("Color3Value", Character) AccessoryC.Name = "AccessoryC" local Accessory2 = Instance.new("ObjectValue", Character) Accessory2.Name = "Accessory2" local Accessory2C = Instance.new("Color3Value", Character) Accessory2C.Name = "Accessory2C" local Skin = Instance.new("ObjectValue", Character) Skin.Name = "Skin" local MColor = Instance.new("Color3Value", Character) MColor.Name = "MColor" --LOAD local LoadSavedData = DataStore:GetAsync(Key) if LoadSavedData then Hair.Value = LoadSavedData[1] HairC.Value = LoadSavedData[2] Hair2.Value = LoadSavedData[3] Hair2C.Value = LoadSavedData[4] Shirt.Value = LoadSavedData[5] Pants.Value = LoadSavedData[6] Accessory.Value = LoadSavedData[7] AccessoryC.Value = LoadSavedData[8] Accessory2.Value = LoadSavedData[9] Accessory2C.Value = LoadSavedData[10] Skin.Value = LoadSavedData[11] MColor.Value = LoadSavedData[12] else local Saving = { Hair.Value, HairC.Value, Hair2.Value, Hair2C.Value, Shirt.Value, Pants.Value, Accessory.Value, AccessoryC.Value, Accessory2.Value, Accessory2C.Value, Skin.Value, MColor.Value, } DataStore:SetAsync(Key, Saving) end end) --STORE DATA WHEN USER LEAVES game.Players.PlayerRemoving:connect(function(plr) --Get Key local Key = "O-"..plr.userId --Data local Data = plr.Data local Character = Data.Character --Stats to Save local Saving = { Character.Hair.Value, Character.HairC.Value, Character.Hair2.Value, Character.Hair2C.Value, Character.Shirt.Value, Character.Pants.Value, Character.Accessory.Value, Character.AccessoryC.Value, Character.Accessory2.Value, Character.Accessory2C.Value, Character.Skin.Value, Character.MColor.Value, } --Saving DataStore:SetAsync(Key, Saving) end)
Simply, (Sorry this is going to SUCK to fix) You cannot save physical objects (Anything created with Instance.new()) You can only save data. So Instead of creating a Color3 with Instance.new("Color3Value") Then changing that data, you would have to save it in a table or something. (You might be able to save a Color3.new())