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

why does my inventory datastore keep printing nil?

Asked by 4 years ago
Edited 4 years ago


game.Players.PlayerAdded:Connect(function(player) print("test") local ExistingData = PlayerDataStore:GetAsync(tostring(player.UserId)) if ExistingData then PlayerData[player.UserId] = ExistingData else PlayerData[player.UserId] = { Currency = 0; --default the currency to 0 Inventory = {}; --default to an empty inventory } end rfunc:FireClient(player, PlayerData[player.UserId].Inventory) print(PlayerData[player.UserId].Inventory) print("test2") end) game.Players.PlayerRemoving:Connect(function(player) PlayerDataStore:SetAsync(tostring(player.UserId),PlayerData[player.UserId]) PlayerData[player.UserId] = nil end) local Inventory = PlayerData[player.UserId].Inventory

this is not where the local inventory variable is located, i had it somewhere else printing inventory, trying to loop through inventory and such and it always came back nil

0
?try using keys like ["Inventory"] or ["Currency"] oilkas 364 — 4y

Answer this question