Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Trying to code a pathfinding AI to go to the players position, but the dummy wont move? please help

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 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.