Soooo I'm using these scripts to save data and don't under stand why I keep receiving these errors:
15:34:53.182 - Cannot convert mixed or non-array tables: keys must be strings
local skinCodes = {
[1000] = {"Raider", "Tom Raider"};
[1001] = {"Raider", "Laura Raider"}
}
function FindSkinCode(name, pos)
for code,file in pairs(skinCodes) do
if file[pos] == name then
return code
end
end
return "Error"
end
function SaveSkins(player)
local key = "player-"..player.UserId
local data = {}
local profile = profiles[player.Name]
local unlockedSkins = {}
for _,skin in pairs(profile.Skins:GetChildren()) do
local m = {}
m[1] = skin.Level.Value
m[2] = skin.EXP.Value
m[3] = {}
for i,variant in pairs(skin.Variants:GetChildren()) do
m[3][i] = FindSkinCode(variant.Name,2)
end
unlockedSkins[FindSkinCode(skin.Name,1)] = m
end
data[1] = unlockedSkins
data[2] = FindSkinCode(profile.Skin.Value,1)
data[3] = FindSkinCode(profile.Skin.Variant.Value,2)
skinData:SetAsync(key, data)
end
The error happens at line 39:
skinData:SetAsync(key, data)
Now, you should know that the values are string values, but when being saved, I search through the skincodes, find where the skin name is, take that index (which is the id), and finally put it in a table to be saved. What am I doing wrong here?
