Weird NPC Movement, similar to what was seen in Ro-Ghoul

I have no clue what the problem is here, I saw the exact same problem back in the day with Ro-Ghoul


It only happens when returning to its original point or anchor as Ive dubbed it. I switched to using MoveToFinished to see if that’d help, but it only confirmed that when the glitch happens, it changes the original point of the Npc. Here part of the script

local debouncemove = false
local returning = false
local anchor = script.Parent.HumanoidRootPart.Position
local MaxDistance = 70
while true do
    wait(0.5)
	melee()
    local target = findNearestTorso(script.Parent.Torso.Position)
    if target ~= nil and (script.Parent.HumanoidRootPart.Position-anchor).magnitude < MaxDistance and not returning  then
		--debouncemove = false
		moving = true
        script.Parent.Humanoid:MoveTo(target.Position, target)
		print ("Move")
		--wait(1)
		--debouncemove = true
		--script.Parent.Humanoid:MoveTo(Vector3.new(0, 0, 0))
    end

	--if debouncemove then
	local target = findNearestTorso(script.Parent.Torso.Position)
		if (script.Parent.HumanoidRootPart.Position-anchor).magnitude > MaxDistance and moving then
		script.Parent.Humanoid:MoveTo(Vector3.new(0, 0, 0))
			debouncemove = false
			returning = true
			wait(.05)
			print("Far")
			script.Parent.Humanoid:MoveTo(anchor)
			humanoid.MoveToFinished:wait()
			debouncemove = true
			returning = false
			moving = false
			print("Far1")
	    end
	--end
	end

I’m sure this question has been answered, I just dont know how to go about phrasing it to look it up. Any clue how to resolve it?
PS : Also note that when I punch in the video, its more like the NPC copies the players torso movement. So when the player is turning to their left with the punch animation, the NPC does too

1 Like