Humanoid:MoveToFinished:Wait() waits max eight seconds before continuing even though the MoveTo has stopped

In my game there is a boss fight, and everything works well except when after the boss charges towards the player. The boss gets a high WalkSpeed then runs toward player. Humanoid:MoveToFinished:Wait() waits the max 8 seconds cutoff for Humanoid:MoveTo() instead of the amount of time the boss takes to get to the player, even though the boss clearly makes it and stops moving.

Entire script:

local dizz = script.Parent.Humanoid:LoadAnimation(script.Dizzy)
local charge = script.Parent.Humanoid:LoadAnimation(script.Charge)
dizz.Looped = true
charge.Looped = true

function dizzy()
	script.Parent.Dizzy.Value = true
	dizz:Play()
	wait(3)
	dizz:Stop()
	script.Parent.Dizzy.Value = false
end

while wait(math.random(10,11)) do
	charge:Play()
	script.Parent.Humanoid.WalkSpeed = 0
	script.Parent.AI.Disabled = true
	script.Parent.AI.DamageTaken.Value = 80
	local plr = workspace:FindFirstChild(script.Parent.AI.Tracking.Value)
	local direction = (script.Parent.HumanoidRootPart.Position - plr.HumanoidRootPart.Position).Unit * 2
	wait(2)
	charge:Stop()
	script.Parent.Humanoid.WalkSpeed = 55
	script.Parent.Humanoid:MoveTo(plr.Torso.Position + direction)
	script.Parent.Humanoid.MoveToFinished:Wait()
	script.Parent.Humanoid.WalkSpeed = 15.9
	script.Parent.AI.DamageTaken.Value = 20
	dizzy()
	wait(1)
	script.Parent.AI.Disabled = false
end

Any help would be appreciated! This isn’t a super professional game so I’m not really using variables

1 Like

That’s because MoveTo() has a timeout of 8 seconds, its corresponding signal MoveToFinished isn’t fired until either the 8 seconds have elapsed or the destination is reached.

I’d recommend connecting a callback to MoveToFinished instead, that way you don’t stall the thread’s execution.

1 Like

If your boss is reaching the player and so reaching the movetofinished point and its not registering, i would suggest two things:

The first is what the roblox reference suggests for the movetofinished function, Disconnecting from the function as shown in their example:

https://developer.roblox.com/en-us/api-reference/event/Humanoid/MoveToFinished

However this might just stop the NPC from chasing you once the disconnect occurs.

Second, i would assign network ownership to nil for the NPC if you haven’t already, this way there is no confusion on the handling of the NPC… this might solve the issue by itself.

1 Like

This works the first time, but after that he stops chasing and is only charging and not getting dizzy

Try just implementing the network ownership and see if that fixes it… without doing the disconnect.

2 Likes

I dont get?? What is network ownership, how do i do that without disconnect. I don’t understand this

I looked into it more, made a for loop that set all the part’s ownership to the server, now it’s working. Thanks!