I’m finishing up this tiles minigames script where, long story short, the player must light up all tiles at once to move on to the next round. However, I have an issue with my for loop. I wasn’t really sure how to check all of a model’s children at once, so I researched and used this method, and it semi-works. However, my problem is, once a tile is passed under the argument that it is neon, it can be changed to plastic afterward, but still pass the argument and move onto the next round. If you don’t know what I mean, there’s a video below. Is there a better way to check all of a model’s children?
Video-
--mainly care about this part
if tableclear then
for _, Children in ipairs(Folder:GetChildren()) do
print(Children)
if (Children.Name ~= "Layout" and Children.Material == Enum.Material.Neon) then
print("table ready to clear")
tableclear = false
elseif (Children.Name ~= "Layout" and Children.Material ~= Enum.Material.Neon) then
tableclear = true
repeat
wait()
if (Children.Name ~= "Layout" and Children.Material == Enum.Material.Neon) then
tableclear = false
print("now neonized")
end
until tableclear == false
end
end
end
--this ends the for loop part/checking if all the parts met the requirement
if not tableclear then
print("tableclear is false!")
if #chosen == MAX_OBJECTS then
table.clear(chosen)
NeonsHIT += 1
if NeonsHIT == 1 then
print(NeonsHIT)
MAX_OBJECTS = 15
tableclear = nil
for _, Children in ipairs(Folder:GetChildren()) do
if (Children.Name ~= "Layout" and Children.Material == Enum.Material.Neon) then
Children.Material = Enum.Material.Plastic
end
end
elseif NeonsHIT == 2 then
print(NeonsHIT)
MAX_OBJECTS = 20
tableclear = nil
for _, Children in ipairs(Folder:GetChildren()) do
if (Children.Name ~= "Layout" and Children.Material == Enum.Material.Neon) then
Children.Material = Enum.Material.Plastic
end
end
end
end
end