Code:
local function PlayerRemoved(PlrRemoving)
local PlayerDataSv = {
--Data
}
local Succes, Error = pcall(function()
DataStore:SetAsync(PlrRemoving.UserId, PlayerDataSv)
end)
if Succes then
print(PlrRemoving.Name.. "'s Data Has Been Saved!")
else
print(PlrRemoving.Name.. "'s Data Did Not Save!")
end
end
Players.PlayerAdded:Connect(function(PlrAdded)
PlayerAdded(PlrAdded)
end)
Players.PlayerRemoving:Connect(function(PlrRemoving)
PlayerRemoved(PlrRemoving)
end)
game:BindToClose(function()
for i, v in Players:GetChildren() do
PlayerRemoved(v)
end
end)