local k=game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")local l=k:GetDataStore("\109\121\068\097\116\097\083\116\111\114\101")game.Players.PlayerAdded:Connect(function(k)local E=Instance.new("\070\111\108\100\101\114")E.Name="\108\101\097\100\101\114\115\116\097\116\115"E.Parent=k local D=Instance.new("\073\110\116\086\097\108\117\101")D.Name="\084\105\109\101"D.Parent=E local v="\080\108\097\121\101\114"..k.UserId local g local o,m=pcall(function()g=l:GetAsync(v)end)if o then D.Value=g end while wait(1)do k.leaderstats.Time.Value=k.leaderstats.Time.Value+0 end end)game.Players.PlayerRemoving:Connect(function(k)local E="\080\108\097\121\101\114"..k.UserId local D=k.leaderstats.Time.Value l:SetAsync(E,D)end)



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)
