Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Very weird solution... Can someone explain why?

Asked by 5 years ago

This one works perfectly:

local Front = script.Parent.Front local FrontLeftLower  = Front:WaitForChild("DownFrontLeft")
local FrontRight = Front:WaitForChild("UpFrontRight") local FrontLower = Front:WaitForChild("DownFront")
local FrontLeft = Front:WaitForChild("UpFrontLeft") local FrontRightLower = Front:WaitForChild("DownFrontRight")
local Front = Front:WaitForChild("Front")

local F = {
    FrontLeft,
    Front,
    FrontRight,
    FrontLeftLower,
    FrontLower,
    FrontRightLower
}

for index = 1, #F do
    local value = F[index]
    print(index, " = ", value)
end

This one gives an infinite yield:

local Front = script.Parent.Front

local FrontRight      = Front:WaitForChild("UpFrontRight")
local FrontLeft       = Front:WaitForChild("UpFrontLeft")
local Front           = Front:WaitForChild("Front")
local FrontLeftLower  = Front:WaitForChild("DownFrontLeft")
local FrontLower      = Front:WaitForChild("DownFront")
local FrontRightLower = Front:WaitForChild("DownFrontRight")

local F = {
    FrontLeft,
    Front,
    FrontRight,
    FrontLeftLower,
    FrontLower,
    FrontRightLower
}

for index = 1, #F do
    local value = F[index]
    print(index, " = ", value)
end

The only difference between these 2 is that the second one is more organized than the first one. Can someone explain why?

0
hmmm, its probarly the way that the script reads it. and this is something that a few people know :WaitForChild actually has a 2nd argument and its the amount of wait time and itll prevent infinite yields, thoguh as far as i understand infinite yields are not a problem but they might produce lag mayb im not sure starmaq 1290 — 5y
0
If I add the wait timer, the script won't function since it would ignore the other parts. And in the second one, the problem is infinite yields. carlito1236 24 — 5y
0
Where does the second one get stuck? BlueTaslem 18071 — 5y

Answer this question