Need help making a humanoid rig move

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make an enemy walk to the player. The enemy has a normal character rig.

  1. What is the issue? Include screenshots / videos if possible!

The rig is not walking at all.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried having the character move using the MoveTo command, and I have tried manually setting the WalkToPart or WalkToPoint. I also have tried making a script with only the MoveTo command and a wait, with a print statement afterward so I could know if it should have worked.

My current script is:

local humanoid = script.Parent.Humanoid
local findNearestPlayer = function() -- this works fine, it locates the nearest player within a certain range and returns their humanoid.
local target

local anim = script.Parent.Walk
local loadAnim = humanoid:LoadAnimation(anim)

wait(3)

while wait(1) do
	
	target = findNearestPlayer()
	
	if target ~= nil then
		
		local realTarget = target.Parent:WaitForChild("HumanoidRootPart")
		humanoid:MoveTo(realTarget.Position, realTarget)
        loadAnim:Play()

	end
	
end

I edited this post after i checked if animations were needed. The animation played, but the rig did not move.

Are you sure your rig isn’t anchored? And why do you have humanoid:MoveTo(realTarget.Position, realTarget) when humanoid:MoveTo(realTarget.Position) does the same

1 Like

Well that was the problem. I have never made an AI before, or made npc’s move, so I didn’t think of that. It moves now.

1 Like