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

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)
