Shortening code

function destroyBarriers(User)
	if not User then return end
	
	if User.Tail >= 1 then
		if User.Depth >= 2 then
			local Blocker = Blockers:FindFirstChild('World1-1')
			if Blocker then
				Blocker:Destroy()
			end
			
			if User.Depth >= 3 then
				local Blocker = Blockers:FindFirstChild('World1-2')
				if Blocker then
					Blocker:Destroy()
				end
			end
			
			if User.Tail > 1 then
				local Blocker = Blockers:FindFirstChild('World1-1')
				if Blocker then
					Blocker:Destroy()
				end
				
				local Blocker = Blockers:FindFirstChild('World1-2')
				if Blocker then
					Blocker:Destroy()
				end
			end
		end
		
		if User.Tail >= 2 then
			if User.Depth >= 2 then
				local Blocker = Blockers:FindFirstChild('World2-1')
				if Blocker then
					Blocker:Destroy()
				end
				
				if User.Depth >= 3 then
					local Blocker = Blockers:FindFirstChild('World2-2')
					if Blocker then
						Blocker:Destroy()
					end
				end
				
				if User.Tail > 2 then
					local Blocker = Blockers:FindFirstChild('World2-1')
					if Blocker then
						Blocker:Destroy()
					end
					
					local Blocker = Blockers:FindFirstChild('World2-2')
					if Blocker then
						Blocker:Destroy()
					end
				end
			end
		end
	end
end

Basically I have a set of blockers named

World1-1
World1-2
World2-1
World2-2

And a player has a Tail and a Depth value. They start off with Tail 1 Depth 1. Upgrade, they get Tail 1 Depth 2, which destroys the World1-1 barrier. Upgrade again they now have Tail 1 Depth 3, this destroys World1-2 barrier.

They upgrade again, now they get Tail 2 Depth 1

I believe something like this could work

function destroyBarriers(User)
    if not User then return end

    for t = 1, User.Tail, 1 do
	    if t == User.Tail then
		    for d = 1, User.Depth, 1 do
			    local Blocker = Blockers:FindFirstChild('World' .. tostring(t) .. '-' .. tostring(d))
			    if Blocker then
				    Blocker:Destroy()
			    end
		    end
	    else
		    for d = 1, 2, 1 do
			    local Blocker = Blockers:FindFirstChild('World' .. tostring(t) .. '-' .. tostring(d))
			    if Blocker then
				    Blocker:Destroy()
			    end
		    end
	    end
    end
end

If i understand what you want to do correctly, this will, say if the User has a Tail value of 2 and a Depth value of 1, It will destroy Barriers:

  • World1-1
  • World1-2
  • World2-1

But not World2-2 as they aren’t up to that yet.

P.S the code may not work, i haven’t tried it