I made a bot that kinda just... runs towards you. But every five seconds it has to stop to update its pathfinding navigation thingy. Can anyone help me improve this script so that the bot stops less?

while true do
	local path = game:GetService("PathfindingService"):ComputeSmoothPathAsync(script.Parent.Torso.Position, game.Workspace:WaitForChild("DaBrainlessOne").HumanoidRootPart.Position, 100)
	local points = path:GetPointCoordinates()
	
	script.Parent.Parent.Points:ClearAllChildren()
	
	for p = 1, #points do
		part = Instance.new("Part")
		part.CanCollide = false
		part.Size = Vector3.new(1,1,1)
		part.Position = points[p]
		part.Anchored = true
		part.Transparency = 0.5
		part.Parent = script.Parent.Parent.Points
		script.Parent.Humanoid:MoveTo(part.Position)
		script.Parent.Humanoid.MoveToFinished:Wait()
	end
		
	print(path.Status)
	
end

4 comments

0

Im pretty sure GetPointCoordinates() as well as the ComputeAsync() methods are deprecated

0

They are deprecated. Why are you using multiple deprecated functions? Can I make a guess and say that you found this script in the toolbox and it is not your own?

0

I mashed together some scripts from tutorials I found on youtube, some dating back to 2014.