Advertisement
SigmaBoy456

Teleport to Each Part Example roblox script

Aug 12th, 2024
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. local player = game.Players.LocalPlayer -- ดึงข้อมูลผู้เล่นท้องถิ่น (ตัวคุณเอง)
  2. local character = player.Character -- เข้าถึงตัวละครของผู้เล่น
  3. local localroot = character:WaitForChild("HumanoidRootPart") -- เข้าถึง HumanoidRootPart ของตัวละคร
  4.  
  5. while task.wait() do -- ลูปไม่สิ้นสุดที่มีดีเลย์
  6. for _, v in pairs(game.Workspace:GetDescendants()) do -- ทำการวนซ้ำผ่านทุกทายาทของ Workspace
  7. -- คุณสามารถเพิ่มชื่อโฟลเดอร์เฉพาะเพื่อเป้าหมายบางโฟลเดอร์ภายใน Workspace
  8. if v:IsA("Part") then -- ตรวจสอบว่าตัวแปร 'v' เป็น Part หรือไม่
  9. localroot.CFrame = v.CFrame -- ย้ายตำแหน่งตัวละครไปยังตำแหน่งของ Part
  10. wait(1) -- ดีเลย์เพื่อป้องกันการย้ายตำแหน่งเร็วเกินไปหรือเกิดข้อผิดพลาด
  11. end
  12. end
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement