So I tried doing [1] but it just errors
--[[ Script --]] function Crate(player,users) local nn = PlayersDataBase:GetAsync(player.UserId,users) PlayersDataBase:SetAsync(player.UserId,users) for i,v in pairs(nn.Foxy_Lover213) do print(v[1]) end end
Here's the table
Players = { ["5_zn"] = { Enabled = false, UserID = "", UserName = "", Rarity = 5, Amount = 0, }, BOF = { Enabled = false, UserID = "", UserName = "BOF", Rarity = 5, Amount = 0, }, ["Foxy_Lover213"] = { Enabled = false, UserID = "343563692", UserName = "Foxy_Lover213", Rarity = 1, Amount = 0, }, ["Lord_Baconnn"] = { Enabled = false, UserID = "429533714", UserName = "Lord_Baconnn", Rarity = 1, Amount = 0, } }
This might help:
function Crate(player,users,what_to_read) local nn = PlayersDataBase:GetAsync(player.UserId,users) PlayersDataBase:SetAsync(player.UserId,users) for i,v in pairs(PlayersDataBase.Foxy_Lover213) do if i == what_to_read then return v end end end
for the third value, put what you want to extract. e.g.
Crate(nil, nil, "Amount")
returns 0 because the "Amount" value of Foxy_Lover213 is 0.
You're index the variable already, you're trying to ask whether the value is a table and the first object inside, that's a huge syntax issue, just to this instead
function Crate(player,users) local nn = PlayersDataBase:GetAsync(player.UserId,users) PlayersDataBase:SetAsync(player.UserId,users) for i,v in pairs(nn.Foxy_Lover213) do print(v, i) end end