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

1 comment
?try using keys like ["Inventory"] or ["Currency"]