I'm trying to make character customization and I'm about done with it but... I need to save the information the player has selected into a DataStore.
This is my code and the error I'm getting is "Cannot store Array in DataStore". I've tried using a for loop to cycle through Value but then it gave me an error saying "Cannot store int in DataStore". I've also tried to cycle through "UpdateStats" but then I remembered that it was a function and not a table. So my question is: How do I fix the error and how does it work so I won't make the same mistake later?
local rep = game:GetService("ReplicatedStorage")
local CharInfo = rep.CharInfo
local DDS = game:GetService("DataStoreService")
local CharInfoDDS = DDS:GetDataStore("CharactInfo")
CharInfo.OnServerEvent:Connect(function(player)
print("This works lol")
--Infomation
local BodyColors = workspace.Character.Head.BrickColor
local PrimaryHair = workspace.Character:WaitForChild("PrimaryHair").HairNum.Value
local PriColorHair = workspace.Character:WaitForChild("PrimaryHair").Handle.BrickColor
local PriNeon = workspace.Character:WaitForChild("PrimaryHair").Handle.Material
local SecondaryHair = workspace.Character:WaitForChild("SecondaryHair").HairNum.Value
local SecColorHair = workspace.Character:WaitForChild("SecondaryHair").Handle.BrickColor
local SecNeon = workspace.Character:WaitForChild("SecondaryHair").Handle.Material
local Gender = rep.MaleFemale.Value
local Trait = rep.TraitChoosing.Value
local Spawn = "Outcast Lands"
--End
local function UpdateStats(Value)
Value[1] = BodyColors
Value[2] = PrimaryHair
Value[3] = PriColorHair
Value[4] = PriNeon
Value[5] = SecondaryHair
Value[6] = SecColorHair
Value[7] = SecNeon
Value[8] = Gender
Value[9] = Trait
Value[10] = Spawn
print(BodyColors, game.Workspace.Character.Head.BrickColor)
for i = 1, #Value do
print(Value[i])
end
return Value
end
CharInfoDDS:UpdateAsync(player.UserId, UpdateStats)
end)

2 comments
You can't save instances to datastores. thats all I know why this error occurs.
You can't save instances to datastores. thats all I know why this error occurs.