I was testing MoveTo
and the finished event. When I noticed that suddenly the start & end points were being deleted from the parts as if something was clearing children.
local Blacklist = {}
local Points = {}
local NextPoint = nil
for _,Points in next,workspace.Road:GetChildren() do
if not Blacklist[Points.Name] then
if not NextPoint then
NextPoint = Points.Name
end
end
end
while wait(1) do
if NextPoint then
if workspace.Road:FindFirstChild(NextPoint) then
local Destination = workspace.Road:FindFirstChild(NextPoint)
script.Parent.Humanoid:MoveTo(Destination.StartPoint.Position)
script.Parent.Humanoid.MoveToFinished:Wait()
script.Parent.Humanoid:MoveTo(Destination.EndPoint.Position)
script.Parent.Humanoid.MoveToFinished:Wait()
Blacklist[Destination.Name] = true
NextPoint = nil
end
else
for _,Points in next,workspace.Road:GetChildren() do
if not Blacklist[Points.Name] then
if not NextPoint then
NextPoint = Points.Name
end
end
end
end
end
So, this is what happened.
It keeps erroring when it exactly reached road 4.
https://gyazo.com/1949db76ca24048085ff5f4b99fee2a6
Is this a bug or is that garbagecollector?