SigmaBoy456

Roblox aimbot example #1

Jul 27th, 2024
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. local player = game.Players.LocalPlayer -- ตัวแปรผู้เล่นหลัก
  2. local character = player.Character -- ตัวแปรตัวละครของผู้เล่น
  3. local localroot = character.HumanoidRootPart -- หัวส่วนหลักของตัวละคร
  4. local UIS = game:GetService("UserInputService") -- บริการตรวจจับการกดแป้นพิมพ์
  5. local Camera = workspace.CurrentCamera -- กล้องหลักในเกม
  6.  
  7. local function closestPlayer() -- ฟังก์ชันหาผู้เล่นที่ใกล้ที่สุด
  8. local target = nil -- เริ่มต้นเป้าหมายเป็นค่าว่าง
  9. local range = math.huge -- กำหนดช่วงเป็นค่าสุดขีด
  10. for _, v in pairs(game.Players:GetPlayers()) do -- วนลูปผ่านผู้เล่นทั้งหมดในเกม
  11. if v ~= player and v.Character then -- ถ้าผู้เล่นไม่ใช่ตัวเองและมีตัวละคร
  12. local JN = v.Character:FindFirstChild("HumanoidRootPart") -- หา HumanoidRootPart ของผู้เล่น
  13. if JN then
  14. local distance = (localroot.Position - JN.Position).magnitude -- คำนวณระยะห่างระหว่างตัวเองกับผู้เล่นอื่น
  15. if distance < range then -- ถ้าระยะห่างน้อยกว่าช่วงที่กำหนด
  16. range = distance -- กำหนดช่วงใหม่เป็นระยะห่างนั้น
  17. target = v -- กำหนดเป้าหมายเป็นผู้เล่นนั้น
  18. end
  19. end
  20. end
  21. end
  22. return target -- คืนค่าผู้เล่นที่ใกล้ที่สุด
  23. end
  24.  
  25. local aimbot = false -- กำหนดสถานะ aimbot เป็นปิด
  26.  
  27. UIS.InputBegan:Connect(function(input) -- ฟังก์ชันที่ทำงานเมื่อมีการกดแป้นพิมพ์
  28. if input.KeyCode == Enum.KeyCode.P then -- ถ้ากดแป้น P
  29. aimbot = not aimbot -- สลับสถานะ aimbot
  30. if aimbot then -- ถ้า aimbot เปิด
  31. spawn(function()
  32. while aimbot == true do -- วนลูปตราบเท่าที่ aimbot เปิด
  33. if aimbot ~= true then return end -- ถ้า aimbot ปิด ให้ออกจากลูป
  34. local Enemy = closestPlayer() -- หาเป้าหมายที่ใกล้ที่สุด
  35. if Enemy and Enemy.Character then -- ถ้าเจอเป้าหมายและมีตัวละคร
  36. local EnemyV = Enemy.Character:FindFirstChild("HumanoidRootPart") -- หา HumanoidRootPart ของเป้าหมาย
  37. local EnemyK = Enemy.Character:FindFirstChild("Humanoid") -- หา Humanoid ของเป้าหมาย
  38. if EnemyV and EnemyK and EnemyK.Health > 0 then -- ถ้าเจอ HumanoidRootPart และ Humanoid ของเป้าหมายและสุขภาพมากกว่า 0
  39. Camera.CFrame = CFrame.new(Camera.CFrame.Position, EnemyV.Position) -- ตั้งกล้องให้หันไปทางเป้าหมาย
  40. end
  41. end
  42. game:GetService("RunService").Heartbeat:Wait() -- รอจนกว่าเฟรมถัดไป
  43. end
  44. end)
  45. end
  46. elseif input.KeyCode == Enum.KeyCode.K then -- ถ้ากดแป้น K
  47. aimbot = false -- ปิด aimbot
  48. end
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment