Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does keys must be strings mean and how can I fix it?

Asked by
HDWC 53
5 years ago

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.

0
It's talking about the dictionary part of the table. When adding things to the dictionary, the format must be [string] = key number. DeceptiveCaster 3761 — 5y
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 Ankur_007 290 — 5y
0
im sorry i dont quite understand can i have more explanation HDWC 53 — 5y

Answer this question