I’ve tried fixing this in many attempts and they never work. When I join a server with two or more players the second player would gain all the string values that first player had. I don’t know why it’s doing this so any help would be appreciated.
--Grabbing the Players Data and Putting it into strings.
if Datastore:GetAsync(player.UserId) then
for i,v in pairs(Datastore:GetAsync(player.UserId)) do
print(player.Name.." Name: " .. v[1] .. " || Class: " .. v[2])
local Item = Instance.new("StringValue", inv)
Item.Name = v[1]
Item.Value = v[2]
end
else
end
--Saving The Players Inventory Folder Into a Table to then Get.
local function OnPlayerRemoving(Player)
for i,v in pairs(Player.InventoryFolder.Inventory:GetChildren()) do
print(Player,v)
table.insert(itemlist, {v.Name, v.Value})
end
Datastore:SetAsync(Player.UserId, itemlist)
print("Saved Inventory")
end
game.Players.PlayerRemoving:Connect(OnPlayerRemoving)```