NPC Patrol Route with Timed Waypoints thumbnail
0 views0 copies0 likes

NPC Patrol Route with Timed Waypoints

Universal script

Copy it, then test it in your own Studio place.

Utilities Verified

Script code

16 lines · 0.6 KB
Download
local humanoid = workspace:WaitForChild("PatrolBot"):WaitForChild("Humanoid")local folder = workspace:WaitForChild("PatrolMarkers")local markers = {}for _, part in folder:GetChildren() do	if part:IsA("BasePart") and tonumber(part.Name) then table.insert(markers, part) endendtable.sort(markers, function(a, b) return tonumber(a.Name) < tonumber(b.Name) end)if #markers == 0 then return endwhile humanoid.Health > 0 do	for _, part in markers do		if humanoid.Health <= 0 then return end		humanoid:MoveTo(part.Position)		humanoid.MoveToFinished:Wait()		task.wait(0.5)-- …open Get script for the full source

About this script

Use a rig named PatrolBot with a Humanoid and a folder named PatrolMarkers containing anchored parts numbered in route order. The server sends the bot toward each marker, then pauses briefly. Humanoid MoveTo handles basic movement on clear ground, making this a good fit for a simple garden path or lobby. Test the first lap with obstacles removed before adding more advanced navigation.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local humanoid = workspace:WaitForChild("PatrolBot"):WaitForChild("Humanoid")
local folder = workspace:WaitForChild("PatrolMarkers")
local markers = {}
for _, part in folder:GetChildren() do
	if part:IsA("BasePart") and tonumber(part.Name) then table.insert(markers, part) end
end
table.sort(markers, function(a, b) return tonumber(a.Name) < tonumber(b.Name) end)
if #markers == 0 then return end
while humanoid.Health > 0 do
	for _, part in markers do
		if humanoid.Health <= 0 then return end
		humanoid:MoveTo(part.Position)
		humanoid.MoveToFinished:Wait()
		task.wait(0.5)
	end
end