SecondsKey = "SecondsPlayed"
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
leaderstats = Instance.new("IntValue")
leaderstats.Parent = player
leaderstats.Name = "leaderstats"
SecondsPlayed = Instance.new("IntValue")
SecondsPlayed.Parent = leaderstats
SecondsPlayed.Name = "Seconds Played"
SecondsPlayed.Value = 0
while wait(1) do
SecondsPlayed.Value = SecondsPlayed.Value +1
end
SecondsPlayed.Value = player:LoadNumber(SecondsKey)
end)
game.Players.PlayerRemoving:connect(function(player)
player:SaveNumber(SecondsKey, player.leadrstats.SecondsPlayed.Value)
end)
The saving doesn't work when I rejoin, I also shutdown all servers and rejoined. It still didn't work.

2 comments
You misspelled leaderstats on line 22. And have the script load the number before the while loop. And put SecondsKey in quotations, since those are supposed to be string values to identify them.
Still won't work... I posted the question again with the new code..