Why is this loop not working?

Hello fellow developers, I wish to make a few parts to dissapear in order then to reappear from the starting order. The script works but it doesn’t loop even though I have added a while True do loop. Got any suggestions on what I can do?

Script is below:

local folder = workspace.dister:GetChildren()
while true do
for _, v in pairs(folder) do
v.Transparency = 1
v.Anchored = false
wait(3)
v.Transparency = 0
v.Anchored = true
end
wait()
end

3 Likes
local folder = workspace.dister:GetChildren()
for _, v in pairs(folder) do
    v.Transparency = 1
    v.Anchored = false
    wait(3)
    v.Transparency = 0
    v.Anchored = true
    wait()
end
4 Likes

I want them to repeat though. So I want them to appear, dissappear and repeat

2 Likes

I would guess that the problem is not what you think it is. Questions:

  • Are the parts visible prior to the initial loop start?
  • Do you only see boop-boop-boop… parts disappearing, and not boop-boop-boop parts appearing?
  • Is there any error in the output?
  • Are you sure the parts are not falling through the ground?
  • Do you have your Transparency settings reversed?
  • Is this in its own script?
  • Did you paste in the code here exactly as it is written?

I think if you can answer all of these questions correctly, you’ll find your answer.

1 Like
code:
local folder = workspace.dister:GetChildren()
while wait() do
  for _, v in pairs(folder) do
    v.Transparency = 1
    v.Anchored = false
    wait(1)
  end
wait(3)
  for _, v in pairs(folder) do
    v.Transparency = 0
    v.Anchored = true
    wait(1)
  end
end
1 Like
  1. Yes the parts are visible when the script is executed. The loop however does not work.
  2. I only see the parts disappear rather appearing.
  3. There is no error inputed on the output.
  4. That I do not know because it disappears first. That’s how I set the script as.
  5. I’m pretty sure they aren’t reversed
  6. Yes it is. It’s placed in ServerScriptService.
  7. Yes I pasted it exactly. I will paste it again underneath.

local folder = workspace.dister:GetChildren()
while true do
for _, v in pairs(folder) do
v.Transparency = 1
v.Anchored = false
wait(3)
v.Transparency = 0
v.Anchored = true
wait()
end
end

1 Like

Else you can use a tween with repeat set to -1

1 Like

That code has the same results as before. It disappears but then doesn’t reappear.

1 Like

I saw anchored set to false, are the parts set to true for CanCollide? Else it will fall through the ground

3 Likes

@Boustifail
indeed
thanks char limit

1 Like

Just try temporarily commenting-out the v.Anchored = false
I’m not sure what you really want it to look like, but I’m guessing that @Aanggoodluck may be correct.

1 Like

Excepted if the parts are CanCollide false when the anchor is false

2 Likes

The fact is, if the anchored is false when the CanCollide is false, part will be destroyed by HeightDestroyPart

2 Likes

And if it doesn’t respawn well that’s because part has been destroyed

2 Likes

I just realised!! My stupidity forgot the difference between Anchored and CanCollide. Thanks!

1 Like

Well here we go, glad to see you got the solution now :+1:

2 Likes

Which was the answer to #4.

1 Like