Advertisement
Anukun_Lucifer

MoveToWayPointsCircle

Aug 24th, 2024
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | Gaming | 0 0
  1. local NPC = script.Parent -- เก็บข้อมูลของNPCที่ตัวสคริปต์ถูกแนบอยู่
  2. local waypoints = script.Parent.Parent.Waypoints -- เข้าถึงโฟลเดอร์ที่เก็บ Waypoints
  3.  
  4. while true do -- เริ่มลูปซ้ำไปเรื่อย ๆ
  5.     -- วนลูปผ่านทุก Waypoint ในโฟลเดอร์ Waypoints
  6.     for waypoint = 1, #waypoints:GetChildren() do
  7.         -- สั่งให้NPCเคลื่อนที่ไปยังตำแหน่งของ Waypoint ปัจจุบัน
  8.         NPC.Humanoid:MoveTo(waypoints[waypoint].Position)
  9.  
  10.         -- รอจนกว่าการเคลื่อนที่ไปยัง Waypoint จะเสร็จสิ้น
  11.         NPC.Humanoid.MoveToFinished:Wait()
  12.  
  13.         -- หยุดรอ 5 วินาทีก่อนที่จะเคลื่อนที่ไปยัง Waypoint ถัดไป
  14.         task.wait(5)
  15.     end
  16. end
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement