This script is supposed to save the players’ data when they leave although it’s not working. Any help is appreciated.
Players.PlayerRemoving:Connect(function(Player)
local Data = {}
Data.Ashes = Player.Ashes.Value
Data.EquippedSkin = Player.EquippedSkin.Value
Data.Skins = {}
for i, v in pairs(Player.Skins:GetChildren()) do
table.insert(Data.Skins, v.Name)
end
DataStore:SetAsync(Player.UserId, Data)
end)