I have a datastore system in my game that will save various player data like their money, health, their inventory, position, ect. I store each in a table in the datastore. I'm new to datastores, so I don't understand it entirely, but when I create another variable in the table for the position (which I don't actually use position, I use the humanoidrootpart's CFrame), it gives me the error:
104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters.
I've tried this with both .Position and .CFrame, but I get the same error. Is there a workaround for this?
Here's the part of my script giving me trouble:
local dataID = plr.UserId local equipped = {} local stored = {} local playerStatus = {} local equipCount = 0 local storedCount = 0 for i,v in pairs(plr.Character.Equipped:GetChildren()) do equipCount = equipCount + 1 table.insert(equipped,equipCount,v.RealName.Value) end for i,v in pairs(plr.Inventory:GetChildren()) do storedCount = storedCount + 1 table.insert(stored,storedCount,v.RealName.Value) end local data = { Pounds = plr.Status.Pounds.Value, Equipped = equipped, Stored = stored, Health = plr.Status.Health.Value, Position = plr.Character.HumanoidRootPart.CFrame, } local success, errormessage = pcall(function() playerData:SetAsync(dataID, data) end) if success then print("Saved") else warn(errormessage) end
You could make Position a dictionary. or something..
local data = { Pounds = plr.Status.Pounds.Value, Equipped = equipped, Stored = stored, Health = plr.Status.Health.Value, Position = { plr.Character.HumanoidRootPart.CFrame.X, plr.Character.HumanoidRootPart.CFrame.Y, plr.Character.HumanoidRootPart.CFrame.Z, }, }