I'm working on a project where when a player goes through a door, the area beyond the door appears, to create a "bigger on the inside than it looks on the outside" effect. I made a folder that contains the parts to appear and made a loop that iterates through all of the children of it, I set their transparency to 0, and CanCollide to true. However, when I tested this the area beyond the door did not appear. After lots of debugging, I found that when this is run:
function LoadFolder(load, folder)
print("1")
local children = folder:GetChildren()
if load == true then
print("2")
for i,child in pairs(children) do
print("3")
--child.Transparency = 0
--child.CanCollide = true
end
elseif load == false then
print("2")
for i,child in pairs(children) do
print("3")
--child.Transparency = 1
--child.CanCollide = false
end
end
print("4")
end
The output is:
1 2 4
It seems to ignore the loop completely!
Can someone please help me figure out what's going wrong?

9 comments
It means that there's nothing in the variable
folder.There are three parts in the folder.
It's the only explanation, the children of "folder" are 0. Check carefully the variable folder when the function is called and provide some screenshot if you still can't figure out the problem
Look: imgur.com/a/PIB0H2P
print #folder and see what it prints.
and that image was taken while the game was running?
It gives the error "attempt to get length of a Instance value"
That image was not taken while the game was running. I just noticed that for some reason ~3 seconds into running the game all of the children of the folder disappear. I don't know what's causing it. I think that's the reason for why the loop isn't working. Why is this happening?
What other scripts affect the folder?