Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local NPC = script.Parent -- เก็บข้อมูลของNPCที่ตัวสคริปต์ถูกแนบอยู่
- local waypoints = script.Parent.Parent.Waypoints -- เข้าถึงโฟลเดอร์ที่เก็บ Waypoints
- while true do -- เริ่มลูปซ้ำไปเรื่อย ๆ
- -- วนลูปผ่านทุก Waypoint ในโฟลเดอร์ Waypoints
- for waypoint = 1, #waypoints:GetChildren() do
- -- สั่งให้NPCเคลื่อนที่ไปยังตำแหน่งของ Waypoint ปัจจุบัน
- NPC.Humanoid:MoveTo(waypoints[waypoint].Position)
- -- รอจนกว่าการเคลื่อนที่ไปยัง Waypoint จะเสร็จสิ้น
- NPC.Humanoid.MoveToFinished:Wait()
- -- หยุดรอ 5 วินาทีก่อนที่จะเคลื่อนที่ไปยัง Waypoint ถัดไป
- task.wait(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement