If npc's speed is bigger that player's, it just does this strange thing like in the video, here's the code I used:
local Players = game:GetService("Players")
local char = script.Parent
local maxaggrorange = 999
local targetdistance = maxaggrorange
local debounce = false
while true do
for i, player in Players:GetPlayers() do
if player.Character then
local humanoid = player.Character:FindFirstChild("Humanoid")
if (char.PrimaryPart.Position - player.Character.PrimaryPart.Position).Magnitude <= targetdistance then
targetdistance = (char.PrimaryPart.Position - player.Character.PrimaryPart.Position).Magnitude
if targetdistance <= maxaggrorange then
char.EnemyHumanoid:MoveTo(player.Character.PrimaryPart.Position)
end
end
end
end
targetdistance = maxaggrorange
task.wait()
end
** You are now Level 1! **