Trying to code an ai that pathfinds to the player's position. No errors are in the output, so not sure why this isn't working. Any help is appreciated :)
script.Parent.HumanoidRootPart.Anchored = false
function move(playerPos)
local human = script.Parent.Humanoid
local torso = script.Parent.HumanoidRootPart
local service = game:GetService("PathfindingService")
local path = service:CreatePath()
path:ComputeAsync(torso.Position,playerPos)
local waypoints = path:GetWaypoints()
for i, v in pairs(waypoints) do
human:MoveTo(v.Position)
human.MoveToFinished:Wait(2)
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Wait()
move(plr.Character:WaitForChild("Humanoid").Parent.HumanoidRootPart.Position)
end)

1 comment
t