Humanoid:MoveTo not working

Hey! I’m scripting NPCs but for some reason Humanoid:MoveTo is not working. Here is the most important snippet of my code:

while true do
	wait()
	for i,v in ipairs(Titans:GetChildren()) do
		local targets = getTargets(v.HumanoidRootPart)
		local nearestTarget = getNearestTarget(targets)
		print(nearestTarget)
		if nearestTarget then
			print("yes")
			local nearestChar = Players[nearestTarget].Character or Players[nearestTarget].CharacterAdded:Wait()
			print(nearestChar)
			local nearestHrp = nearestChar.HumanoidRootPart
			print(nearestHrp)
			followTarget(v.Humanoid, nearestHrp)
		end
	end
end

It does print everything. Here is the followTarget function

local function followTarget(titanHumanoid, hrp)
	print("Moving")
	titanHumanoid:MoveTo(hrp.Position, hrp)
end

It does print “Moving” but for some reason it’s not.

How I created the NPC: I played the game and copied my character. Then I pasted it into the game when I stopped. I changed some stuff like the hair and stuff, so that shouldn’t be a problem I guess…

Here is a video about the behaviour if needed (you can also see my output):
https://streamable.com/tcths9

Is anything anchored? If so, unanchor them

1 Like

Nope, nothing is anchored, but probably the NPC is the problem, right?

Pretty sure it could be the size of this titan?

1 Like

It’s just increasing the scales;

local function makeBigger(humanoid, meters)
		local makeBigger = {
			humanoid.BodyDepthScale;
			humanoid.BodyHeightScale;
			humanoid.BodyTypeScale;
			humanoid.BodyWidthScale;
			humanoid.HeadScale;	
		}
		for i,v in ipairs(makeBigger) do
			v.Value = meters
		end
	end

Removed that function, now they are average size (1), it’s still not working.

I still need help, sorry for the bump, but if you have any idea what could cause this, please tell me.

Try using MoveTo on a normal npc, might be a roblox problem.

1 Like

Just noticed, when trying to do

workspace.Titans.Titan.Humanoid:MoveTo(workspace.GEILER123456.HumanoidRootPart.Position)

in the command box, they are not coming to me, so that means something is wrong with the NPCs.

Some information about them:

I made a Titans folder in the workspace. They are in that folder.
image
This is how they look like in the Explorer:
image

Copy everything inside of “Animate”, make a new SERVER script called “Animate” and paste everything inside, then if you click play you will get an error about something with emotes, this isn’t a big deal, you can just delete the entire emotes function.

1 Like

That’s not the problem, they can also walk without animations.
I did

workspace.Titans.Titan.Humanoid:MoveTo(workspace.GEILER123456.HumanoidRootPart.Position)

On the server, while having a different NPC and it worked, but in the script it doesn’t, for some reason.
Here is the script:

while true do
	wait()
	for i,v in ipairs(Titans:GetChildren()) do	
		local targets = getTargets(v.HumanoidRootPart)
		local nearestTarget = getNearestTarget(targets)
		print(nearestTarget)
		if nearestTarget then
			print("yes")
			local nearestChar = Players[nearestTarget].Character or Players[nearestTarget].CharacterAdded:Wait()
			print(nearestChar)
			local nearestHrp = nearestChar.HumanoidRootPart
			print(nearestHrp)
			v.Humanoid:MoveTo(nearestHrp.Position)
			print("Moving")
		end
	end
end

Everything does print.

I know they can walk without animations, just something you should do.

1 Like

Figured it out!!!
Solution:
I did

for i,v in ipairs(Titans:GetChildren()) do

but Titans was a variable for the titan models in ReplicatedStorage, not the one in workspace :smiley:

Doing for i,v in ipairs(workspace.Titans:GetChildren()) works.

I was gonna say print out the names of the titans, but congratulations on figuring it out.

1 Like