I'm working on the saving system for my tycoonish game. It's mostly done and working but I keep getting this one error and no matter what i cant fix it. 08:37:31.179 - Cannot convert mixed or non-array tables: keys must be strings

08:37:31.180 - Stack Begin

08:37:31.180 - Script 'ServerScriptService.Player_Handler.SaveData', Line 17 - field Save

08:37:31.180 - Script 'ServerScriptService.Player_Handler', Line 50

08:37:31.181 - Stack End

local Data = {}

local httpservice = game:GetService("HttpService")

local dataservice = game:GetService("DataStoreService")

  

  

function Data.Save(plr, base)

local key = plr.UserId

local base_save = dataservice:GetDataStore("Base")

local save = {}

for i, item in pairs(base.ItemHolder:GetChildren()) do

if item:IsA("Model") then

local cframe = base.Part.CFrame:inverse() * item:GetPrimaryPartCFrame()

local save_cframe ={item.Name, {cframe.X, cframe.Y, cframe.Z}}

table.insert(save, 0, save_cframe)

end

end

base_save:SetAsync(key, save)

end

  

function Data.Load(plr, base)

local key = plr.UserId

local base_save = dataservice:GetDataStore("Base")

local saved = base_save:GetAsync(key)

local loaded = {}

for i, coordinates in pairs(saved or {}) do

local cords = CFrame.new(coordinates[2][1], coordinates[2][2], coordinates[2][3])

local newcords = base.Part.CFrame * cords

table.insert(loaded,0, newcords)

end

return loaded

  

end

return Data

please help me, and thanks in advance.

3 comments

0

It's talking about the dictionary part of the table. When adding things to the dictionary, the format must be [string] = key number.

0

Dictionaries can have instances as their keys and all non nil values in general as seen on the Wiki: https://developer.roblox.com/articles/Table#creating-a-dictionary

0

im sorry i dont quite understand can i have more explanation