How can I prevent zombies in my tower defense game from stopping for half a second at each point they go to?

How would I do that? I can try to see if it makes a difference.

loop through all the zombies and do SetNetworkOwner(nil) something like this:

for index, part in pairs(zombiesFolder:GetDescendants()) do
    if part:IsA("BasePart") then
        part:SetNetworkOwner(nil)
    end
end

Instead of making a custom wait function. Just use Humanoid.MoveToFinished:Wait()

Try this now this will work better

local hum = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

local nodes = game.Workspace.Path1:GetChildren()

local targetReached = false
local function moveTo(targetPoint)
	targetReached = false
	local connection
	connection = hum.MoveToFinished:Connect(function(reached)
		targetReached = true
		connection:Disconnect()
		connection = nil
	end)

	-- start walking
	hum:MoveTo(targetPoint)
end

for _, node in ipairs(nodes) do
	moveTo(node.Position)
	
	
	repeat
		wait()
	until targetReached
end

I heard that there was a bug with that though on a another post. Pretty sure you just set their network owner to nil.

I’ll check it out once I’m on pc.

1 Like

For my game, I clone my zombies out of replicated storage and onto the path. Would I use that script on the clones or the ones in replicated storage?

i think you have to do it on the cloned zombies

I feel like it would make more sense doing it on the ones in replicated storage because when they get cloned, the clones also get the effect from it.

you can try both of the ways then

My bad, actually it only works on the cloned zombies because you can only change it to things in the workspace

It works though. Thanks a lot!

1 Like

It works well on my normal enemies, but I have a giant boss and it just skips a lot of the path. Is it because of it’s speed or something?

This thing can happen because the script takes node depending on their order in the folder

So putting numbers at the end of them doesn’t really make a difference?

I’m not sure about this but I think it is

I will give you a better way

Alright. Tell me when you finish it.

Now go to the nodes folder and rename the nodes starting with number 1

Example of the first step, name it 1 next step 2 etc

and replace the loop function to

for i = 1, #nodes do
	local FindNode = game.Workspace.Path1:FindFirstChild(i)
	
	moveTo(FindNode.Position)
	
	repeat
		wait()
	until targetReached
end

Please never repeat wait() it’s so incredibly inefficient and random. If you’re going that route use a custom wait function.

To answer the question:
I use distance/walkspeed - 0.05 with a custom wait function and there is no stuttering, but I also have a custom path-follow handler too.

3 Likes