Why is it that Humanoid:MoveTo() will not work for my script?
Hello, i am creating a script where when the humanoid is damaged, it walks to the closest player in range. But it isn't working, when everything is correct and where it should walk.
Script:
01 | local runService = game:GetService( "RunService" ) |
11 | script.Parent.Enemy.Changed:Connect( function (plays) |
12 | local hum = script.Parent.Enemy |
16 | if hum.Health < oldHealth then |
19 | oldHealth = hum.Health |
25 | for i, v in pairs (game.Players:GetPlayers()) do |
26 | local magnitude = (script.Parent.HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).Magnitude |
28 | if magnitude < mag then |
41 | initiate = initiate + 1 |
51 | oldHealth = hum.Health |
57 | runService.Stepped:Connect( function (plays) |
58 | if targetFollow ~ = nil then |
59 | if oldInitate ~ = initiate then |
60 | local magnitude = (script.Parent.HumanoidRootPart.Position - targetFollow.HumanoidRootPart.Position).Magnitude |
62 | if magnitude < range then |
63 | script.Parent.Enemy:MoveTo(targetFollow.HumanoidRootPart.Position, targetFollow.HumanoidRootPart) |
script.Parent.Enemy:MoveTo(targetFollow.HumanoidRootPart.Position, targetFollow.HumanoidRootPart)
is the important line
targetFollow is my player, wont work. Please help