Removing anything from a set number and below

So I have a folder with parts that block a player from reaching further into a stage. Those block are labelled:

World1_1
World1_2
World1_3
World2_1

etc…
Now I want to loop through all of them and remove the ones based on a players 2 stats.

print(NextTail.Number, NextTail.Depth) -- prints 3, 2

So in the above example, 3 is the first number and 2 is the second number. So with this example, it should delete:

World1_1
World1_2
World1_3
World2_1
World2_2
World2_3
World3_1

BUT leave World3_2

In order to do that you could use something like this.

for i=1, NextTail.Number do
for j=1, NextTail.Depth do
if i == NextTail.Number and j == NextTail.Depth then return end
-- Remove Worldi_j
end
end
1 Like