So basically I made an Enemy NPC with a custom character. When I try to use ":MoveTo()" the character stands still and looks at the character, sometimes shuffling a bit. I would love to have some insight into the problem. Thanks.

Main CodeBlock with moving:

		while wait() do
			if #game.Players:GetPlayers() > 0 and P.Humanoid.Health > 0 then
				for k,v in pairs(game.Players:GetPlayers()) do
					local Chr = v.Character
					if Chr ~= nil then
						if (P.HumanoidRootPart.Position - Chr.HumanoidRootPart.Position).Magnitude < MaxDistance then
							if (P.HumanoidRootPart.Position - Chr.HumanoidRootPart.Position).Magnitude < AttackDistance then
								 -- Leaving this part out
								
							else	
								P.Humanoid:MoveTo(P.HumanoidRootPart.Position)
								break
								
							end	
						end
					end
				end
			end

2 comments

0

where did you declare the maxdistance variable

0

I declared it at the beginning, before the loop