That’s probably because you didn’t connected it into the game:BindToClose() function which will run everytime the Server is about to close. It’s always good to use this since it will save the Data of all Players whenever the Server closes. Add this code below at the end of your Script - This should take care of it.
Another thing that you can do is try using ProfileService - A powerful module for Saving, Managing and Updating Data, It is currently the best Module for Data Saving so far and i really recommend you using it.
game:BindToClose(function()
-- Always run this on a pcall in-case some Internal error
-- or whatever else happens
pcall(function()
for Index, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Index and Player then
local success, errormessage = pcall(function()
Datastore:SetAsync("time-"..player.UserId,player.leaderstats.Time.Value)
Datastore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Rebirths.Value)
end)
end
end
end)
end)