Im trying to save a table with datastore but it never works. Please help!
local dss = game:GetService("DataStoreService") local ds = dss:GetDataStore("HatInv") game.Players.PlayerAdded:Connect(function(p) local Data = ds:GetAsync("User-"..p.UserId) local Data2 = table.unpack(Data) if Data2 ~= nil then for i, v in pairs(Data2) do local findObject = game.ReplicatedStorage.Hats:FindFirstChild(v):Clone() findObject.Parent = p:WaitForChild("PlayerGui").ScreenGui.Inventory.ScrollingFrame end else warn(Data) end end) game.Players.PlayerRemoving:Connect(function(p) local ToBeSaved = {} for i, v in pairs(p:WaitForChild("PlayerGui").ScreenGui.Inventory.ScrollingFrame:GetChildren()) do if v.ClassName == "Frame" then table.insert(ToBeSaved, v.Name) else end end ds:SetAsync("User-"..p.UserId, ToBeSaved) end)
Thanks in advance