Value not getting removed from array sometimes?

So basically. I’m tryin’ to clean up an array. I’m tryin’ to remove 2 values from it called “Start” and “1”.

It does work. But sometimes it just removes 1 and ignores the other?? does anyone know why this might happen?? i cant really see anythin’ wrong with my code that could cause this behavior. I also wait for everything on the client to load before i clean up the array???

My current code:

-- // Funcs
		local function CleanUpArray(Array)
			local New = table.clone(Array)
			for Index: number, Value: BasePart in New do
				if Value.Name:lower() == "start" or Value.Name:lower() == "1" then
           return New
		-- // End
		-- // Vars
		local Children = CleanUpArray(Nodes:GetChildren())
		-- // End

Every time an item is removed, the values shift downwards to fill the gap. The best solution is to iterate backwards over the array instead of forwards.


Ooohhh i didn’t know about that. Ha guess i learnt shmtin new today also :smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.