local dataStoreService = game:GetService("DataStoreService")
local timeData = dataStoreService:GetDataStore("TimeData")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Time = Instance.new("IntValue",leaderstats)
Time.Name = "Time"
local success , getValue = pcall(function()
return timeData:GetAsync(player.UserId) or 0
end)
if success then
print("the load was successful")
else
warn(getValue)
end
Time.Value = getValue
print ("Loaded Value "..getValue)
game.Players.PlayerRemoving:Connect(function(player)
local succes , erra = pcall(function()
timeData:UpdateAsync(player.UserId,function(wtf)
if Time.Value > wtf then
return Time.Value
end
end)
end)
if not succes then
warn(erra)
end
print(player.Name.." has left the server".."("..player.UserId..")")
end)
end)

2 comments
I love u
thanks, if this helped you can mark this as answer :D