if earnTime>0 and earnAmount~=0 then script.playerObject.Changed:connect(function(K)if K and K:IsA("\080\108\097\121\101\114")then for L,M in next,playersToIncrement do if M==K then return end end table.insert(playersToIncrement,K)end script.playerObject.Value=nil end)while wait(earnTime)and wait()do for K,L in next,playersToIncrement do if L then local K=L.leaderstats:FindFirstChild(cashName)if K then K.Value=K.Value+earnAmount end else table.remove(playersToIncrement,K)end end end else script:Destroy()end
-- This script only needs to run if increment values actually exist.
if earnTime > 0 and earnAmount ~= 0 then
	-- The first shop in the game that loads will parent this script to
	-- ServerScriptService. After that, the other shops will just change
	-- the value of playerObject, and the player gets added to the increment list.
	script.playerObject.Changed:connect(function(value)
		if value and value:IsA("Player") then
			for _, player in next, playersToIncrement do
				if player == value then
					return
				end
			end
			table.insert(playersToIncrement, value)
		end
		script.playerObject.Value = nil
	end)

	while wait(earnTime) and wait() do
		for i, player in next, playersToIncrement do
			if player then
				local cash = player.leaderstats:FindFirstChild(cashName)
				if cash then
					cash.Value = cash.Value + earnAmount
				end
			else
				table.remove(playersToIncrement, i)
			end
		end
	end
else
	script:Destroy()
end
