Issues with helping the script know what table to save and load data in

So i’ve been trying to make a multi saving and loading data store. The leaderstats itself is working perfectly fine, same as the saving. But I am having issues of how I should tell the script what table to get and load from.

The loading part of the script:

 local info = data:GetAsync("Data"..plr.UserId)
        local s, e = pcall(function()
        end)
        if s then
            Cash.Value = info.Money
            Gems.Value = info.Diamonds
        else
            print("Couldn't load  data.")
            warn(e)
        end
    end)

info.Money is indexing nothing. I am guessing same goes with “Gems”.

The table found in SetAsync (saving) part of the script:

local tab = {Diamonds = plr.leaderstats.Diamonds.Value, Money = plr.leaderstats.Money.Value}

Any help is appreciated.

Your code is confusing, you have a pcall that is empty where the info line should be and give us more information on “Cash” and “Gems”, are they supposed to be info.Cash/Gems or not?

They are both intvalues being stored inside a folder named “leaderstats” and that is being stored inside the player. Sorry about that. Not sure, but I was attempting to get the values I told the table to get (local tab = {Diamonds = plr.leaderstats.Diamonds.Value, Money = plr.leaderstats.Money.Value} ) and put it into the intvalues I set up.

Try putting the info line inside the pcall function and see if it works.

So far I tried that before I asked the problem I was having.

I am not sure, but I did something like this:

local info
local s, e = pcall(function()
info = data:GetAsync(“data_”…plr.UserId
end

If this didn’t work then I don’t have any solutions as far I can see, the only thing you can do is adding debug prints such as this

print(1), print(2) etc

to help debug the problem.

1 Like