local d=game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")local R=d:GetDataStore("\109\121\068\097\116\097\083\116\111\114\101")game.Players.PlayerAdded:Connect(function(d)local v=Instance.new("\070\111\108\100\101\114")v.Name="\108\101\097\100\101\114\115\116\097\116\115"v.Parent=d local b=Instance.new("\073\110\116\086\097\108\117\101")b.Name="\084\105\109\101"b.Parent=v local x="\080\108\097\121\101\114"..d.UserId local i local L,f=pcall(function()i=R:GetAsync(x)end)if L then b.Value=i end while wait(1)do d.leaderstats.Time.Value=d.leaderstats.Time.Value+0 end end)game.Players.PlayerRemoving:Connect(function(d)local v="\080\108\097\121\101\114"..d.UserId local b=d.leaderstats.Time.Value R:SetAsync(v,b)end)
-----------------------------------------------| Save Stats |------------------------------------------------------------

local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Time = Instance.new("IntValue")
	Time.Name = "Time"
	Time.Parent = leaderstats

	local playerUserId = "Player" .. player.UserId

	local data

	local success, errormessage = pcall(function()
		data = myDataStore:GetAsync(playerUserId)
	end)

	if success then
		Time.Value = data
	end

	while wait(1) do
		player.leaderstats.Time.Value = player.leaderstats.Time.Value + 0 --Don't change it or it will make it go up twice
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local playerUserId = "Player" .. player.UserId

	local data = player.leaderstats.Time.Value

	myDataStore:SetAsync(playerUserId, data)
end)
