You are checking is 1 player is in the game:
check = function()
if #PlayersService:GetPlayers() == 1 then
return false
else
return true
end
end
You have a condition for true but you don’t have a condition for false:
PlayersService.PlayerRemoving:Connect(function(player)
if check() == true then
local UUID = player.UserId
local success, err = pcall(function()
SaveData(player)
end)
if success then
LivePlayerData[UUID] = nil
warn("DATA SAVED!")
else
LivePlayerData[UUID] = nil
print(err)
-- run function to attempt another save, the data is saved to a temporary "failed save" table to protect the data from simply being thrown away once the player leaves.
warn("DATA DID NOT SAVE!")
end
end
end)