You can write your topic however you want, but you need to answer these questions:
- 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.
- What is the issue? Include screenshots / videos if possible!
The rig is not walking at all.
- 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.