So recently for my zombie controller, I started looking for examples to make it more efficient, during that I saw people doing what I shown below, after the path was created to the player, and the zombie starts chasing the player.
repeat
humanoid:MoveTo(Character.Root.Position)
wait()
until CONDITION
Since :MoveTo() creates a new thread when called aren’t they potentionally creating a thread every iteration, which leads to the server crash overtime. Does roblox automatically kill the moveto thread when its called a second time? The reason I’m confused is a lot of controller script’s do this.
Where in the docs does it say it creates a new thread each time?
My understanding, as per the docs, is that this simply changes the WalkToPoint property, and based on that understanding, continuing to change this property again and again will simply update where the humanoid is walking to, rather than creatings tons of competing threads all trying to walk to different places.
By all means correct me if you have more authoritative info - I’m just using the docs.
Oh ok, so humanoid.MoveToFinished:Wait(), is actually bad for this scenerio, the whole point of the Repeat loop was to update the zombies walkDestiny, if the player moves ect. If I yielded the code if the player moved the zombie would finish walking to the old destiny and then walk to the new destiny, which is bad.
This isn’t the pathfinding code, it’s the code which runs once the player is in line of sight of the zombie.