Greetings! I'm working on a DataStore of which saves the name of the Value and also the Value itself, the code itself is working fine other than when I add the 'v.Value' within the table.insert -
Output is throwing out: "Bad argument:12 #2 to 'insert' Number Expected, got string.".
Any help would be appreciated.
local SaveID = 'ID:' .. Player.userId local save = {} for i,v in pairs(Player:WaitForChild("PlayerData"):GetDescendants()) do if v:IsA("NumberValue") or v:IsA("StringValue") then table.insert(save, {v.Name, v.Value, v.ClassName}) print("Name: " .. v.Name .. " CP: " .. v.Value .. " IsA: " .. v.ClassName) else end end DSService:SetAsync(SaveID, save) print("Saved!")
EDIT: First half is working now, however my current issue is returning the values back to the server and 'loading' them.
local SaveID = 'ID:' .. Player.userId local GetSaved = DSService:GetAsync(SaveID) if GetSaved then for i,v in pairs (GetSaved) do local Saved = Instance.new("NumberValue", Player:WaitForChild("PlayerData")) Saved.Name = GetSaved[2] Saved.Value = GetSaved[3] end else print("Save file not found") end
If you wanted to make a string index, use this:
save[v.Name] = v.Value