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

Why does it find nothing in the table when there clearly is?

Asked by 2 years ago
Edited 2 years ago

Basically, I have an inventory script where you buy skins and it adds to a table and saves it, etc. But for some reason, whenever in a local script I do this:

local thing = require(rs:WaitForChild("Inventory"))

for i, v in pairs(thing) do
    print(i)
    print(v)
end

It only shows table brackets: {}

But when I do something similar on the server-side:

game.Players.PlayerRemoving:Connect(function(plr)

    ds:SetAsync(plr.UserId, statstable["Skins"]) 
    for i, v in pairs(statstable["Skins"]) do -- look here
        print(v)
    end -- to here

end)

For some reason that works. keep in mind the variables are both require(rs:WaitForChild("Inventory")) so I don't know how this could happen.

The second script's output works just fine, and prints out all the skins I own in a list order.

Please comment if you know anything on how to fix this, it's becoming irritating. Thanks!

Answer this question