Basically I Save The Items In a Backpack And Then When They Rejoin It Gives Them Those Items But A Problem Is That When They Return The Table Is Blank Even Though When They Leave The Table Does Save
Here Is My Script
local DataStore = game:GetService("DataStoreService")
local Data = DataStore:GetDataStore("MS_PopItTrading_Inventory_Data")
game.Players.ChildAdded:Connect(function(Plr)
local Key = Plr.UserId
if Data:GetAsync(Key) == nil then
local Inventory = {"Blank"}
Data:SetAsync(Key,Inventory)
print(Data:GetAsync(Key))
else
for i, value in pairs(Data:GetAsync(Key)) do
local Pop = game.Lighting.PopIts:FindFirstChild(value)
if Pop then
local Clone = Pop:Clone()
Clone.Parent = Plr.Backpack
end
end
print(Data:GetAsync(Key))
end
end)
game.ReplicatedStorage.InventorySave.OnServerEvent:Connect(function(Plr)
local Key = Plr.UserId
local Inventory= {}
local Amount = 0
for i,v in pairs(Plr.Backpack:GetChildren()) do
local Amount = Amount + 1
table.insert(Inventory,Amount,v.Name)
end
local Success, Error = pcall(function()
Data:SetAsync(Key,Inventory)
end)
if Error then
warn(Error)
end
end)
