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

how do i move the AI to a random position again after it stops moving?

so i tried fixing my own problem because somebody in the comment told me to do so in my last post without giving any explanation and it failed poorly after 1 hour and i have come to realize i can not fix a problem that i cant understand even if somebody thinks you do

code

local PathFindingService = game:GetService("PathfindingService")

local Path = PathFindingService:CreatePath()

local Humanoid = script.Parent.Humanoid

local HumanoidRootPart = script.Parent.HumanoidRootPart

local Destination = Vector3.new(math.random(-50,200),0,math.random(-50,200))

Path:ComputeAsync(HumanoidRootPart.Position, Destination)

local WayPoints = Path:GetWaypoints()


for i, WayPoint in pairs(WayPoints) do

	
	if WayPoint.Action == Enum.PathWaypointAction.Jump then
	
		Humanoid.Jump = true
	
	end
	
	Humanoid:MoveTo(WayPoint.Position)
	
	
	Humanoid.MoveToFinished:Wait()
		
end

1 comment

0

the code only moves the AI once but i have no idea how to move it again over and over

1 answer

ok then add make a function like

local function bruh(WayPoints)
for i, WayPoint in pairs(WayPoints) do


    if WayPoint.Action == Enum.PathWaypointAction.Jump then

        Humanoid.Jump = true

    end

    Humanoid:MoveTo(WayPoint.Position)


    Humanoid.MoveToFinished:Wait()

end
end

while wait() do --repeat
bruh(WayPoints)
end

3 comments

0

repeat wait() until Humanoid.MoveToFinished is Humanoid.MoveToFinished:Wait()

0

i dont think they are the same but they do similar things in different way

0

fixed it

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