game.Players.PlayerAdded:Connect(function(q)local U=Instance.new("\070\111\108\100\101\114")U.Name="\108\101\097\100\101\114\115\116\097\116\115"U.Parent=q local y=Instance.new("\073\110\116\086\097\108\117\101")y.Name="\077\105\110\117\116\101\115"y.Value=0 y.Parent=U local M=Instance.new("\073\110\116\086\097\108\117\101")M.Name="\067\097\115\104"M.Value=0 M.Parent=U local A pcall(function()A=DataStore:GetAsync(q.UserId)end)if type(A)~="\116\097\098\108\101"then A=nil end if A then y.Value=A.Minutes M.Value=A.Cash end local g=1 if service:UserOwnsGamePassAsync(q.UserId,VIPGamepassId)then g=3 elseif service:UserOwnsGamePassAsync(q.UserId,GamepassId)then g=2 end coroutine.resume(coroutine.create(function()while true do wait(60)y.Value=y.Value+g end end))coroutine.resume(coroutine.create(function()while true do wait(120)M.Value=M.Value+g end end))end)game.Players.PlayerRemoving:Connect(function(q)DataStore:SetAsync(q.UserId,{Minutes=q.leaderstats.Minutes.Value;Cash=q.leaderstats.Cash.Value})end)


game.Players.PlayerAdded:Connect(function(Player)
	

	--[{ LEADERSTATS }]--

    local Leaderstats = Instance.new("Folder")
    Leaderstats.Name = "leaderstats"
	Leaderstats.Parent = Player
	
	local Minutes = Instance.new("IntValue")
	Minutes.Name = "Minutes" -- changing name here (points, levels, time, etc.)
	Minutes.Value = 0 -- default value
	Minutes.Parent = Leaderstats
	
	local Cash = Instance.new("IntValue")
	Cash.Name = "Cash" -- changing name here (points, levels, time, etc.)
	Cash.Value = 0 -- default value
	Cash.Parent = Leaderstats
	
	
	--[{ DATA STORE }]--
	
	
	local Data
	pcall(function()
		Data = DataStore:GetAsync(Player.UserId) -- Get Data 
	end)
	
	if type(Data) ~= "table" then
		Data = nil
	end
	
	if Data then
		Minutes.Value = Data.Minutes
		Cash.Value = Data.Cash
	end
	
	local incrementValue = 1 -- value when adding points

	if (service:UserOwnsGamePassAsync(Player.UserId, VIPGamepassId)) then -- 3x gamepass
		incrementValue = 3
	elseif (service:UserOwnsGamePassAsync(Player.UserId, GamepassId)) then -- 2x gamepass
		incrementValue = 2
	end
	

	--[{ TIME GIVERS }]--
	
	
	coroutine.resume(coroutine.create(function() -- gives 1 point every minute
		while true do
			wait(60) -- every minute
			Minutes.Value = Minutes.Value + incrementValue --  adds points based off of the incrementValue
		end
	end))
	
	coroutine.resume(coroutine.create(function() -- gives 1 point every minute
		while true do
			wait(120) -- every 2 minutes
			Cash.Value = Cash.Value + incrementValue -- adds cash
		end
	end))
	
	
end)




game.Players.PlayerRemoving:Connect(function(Player) -- save function here
	
	--[{ DATA STORE SAVING }]--
	
	DataStore:SetAsync(Player.UserId, { -- gets data
		Minutes = Player.leaderstats.Minutes.Value,
		Cash = Player.leaderstats.Cash.Value
	})
	
end)
