Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Do all DataStore values return as a table?

Asked by 1 month ago
Edited 1 month ago
Remotes.SaveStats.OnServerEvent:Connect(function(plr)
    local pid = plr.UserId
    local Stats = plr.PlayerStatTable
    local SaveStats= {}
    for _,v in pairs(DeFolder(Stats)) do
        if DeFolder(v) then
            local Dictionary={}
            for _,va in pairs(v:GetChildren()) do
                Dictionary[va.Name] = va.Value
            end
            SaveStats[v.Name] = Dictionary
        else
            SaveStats[v.Name] = v.Value
        end
    end
    Mod.SaveStats(pid,SaveStats)
    return SaveStats
end)

But when I load it with

Remotes.LoadStats.OnServerEvent:Connect(function(plr)
    local pid = plr.UserId
    local Stats = plr.PlayerStatTable
    local LoadedStatTable = Mod.LoadStats(pid)
    for a_,v in pairs(LoadedStatTable) do
        for _,va in pairs(v) do
            print(va)
        end
    end

end)

This returns index:table for all of the items. Every Single value is a table. And the full table looks like this. Idk why it's happening

local StatFormula = {
["Level"] = 1,
["Inventory"] = {},
["Pets"] = {},
["MaxHealth"] = 100,
["MaxStamina"] = 100,
["BeastCoins"] = 0,
["Diamonds"] = 0,
["Scrolls"] = 0,
["EnchantedScrolls"] = 0,
["Metal"]=0,
["Wood"]=0,
["Cloth"]=0,
["GodFiber"]=0,
["GodDiamond"]=0
}

Anyone know what's happening? Thanks!

0
Why is the OnServerEvent listener returning a value? Use a remote function instead. incapaxian 1315 — 1mo
0
ok Simulants 27 — 1mo

Answer this question