From DDD, 4 Days ago, written in Lua.
Embed
  1. -- Dungeon Leveling AutoFarm (ปรับให้ปลอดภัยจากศัตรู)
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  6. local humanoid = character:FindFirstChildOfClass("Humanoid")
  7.  
  8. local runService = game:GetService("RunService")
  9. local userInput = game:GetService("UserInputService")
  10. local autoFarm = true
  11. local HIT_RANGE = 10
  12.  
  13. -- ป้องกันการถูกตีโดยย้ายตัวละครขึ้นสูง
  14. local function moveCharacterOutOfRange()
  15.     if humanoidRootPart then
  16.         humanoidRootPart.Anchored = true
  17.         humanoidRootPart.Position = Vector3.new(0, 9999, 0)
  18.         workspace.CurrentCamera.CameraSubject = humanoid
  19.         print("✅ ปลอดภัยจากศัตรูแล้ว")
  20.     end
  21. end
  22.  
  23. local function getClosestMob()
  24.     local closestMob = nil
  25.     local closestDistance = math.huge
  26.     for _, mob in ipairs(workspace.Characters:GetChildren()) do
  27.         if mob:IsA("Model") and mob ~= character and mob:FindFirstChild("HumanoidRootPart") then
  28.             local dist = (mob.HumanoidRootPart.Position - humanoidRootPart.Position).Magnitude
  29.             if dist < closestDistance then
  30.                 closestDistance = dist
  31.                 closestMob = mob
  32.             end
  33.         end
  34.     end
  35.     return closestMob
  36. end
  37.  
  38. local function isInRange(mob, range)
  39.     local mobRootPart = mob:FindFirstChild("HumanoidRootPart")
  40.     if not mobRootPart or not humanoidRootPart then return false end
  41.     return (mobRootPart.Position - humanoidRootPart.Position).Magnitude <= range
  42. end
  43.  
  44. local function equipWeapon()
  45.     local eventFolder = game:GetService("ReplicatedStorage"):FindFirstChild("Events")
  46.     if eventFolder and eventFolder:FindFirstChild("WeaponsEvent") then
  47.         eventFolder.WeaponsEvent:FireServer("Equip/UnEquip")
  48.     end
  49. end
  50.  
  51. equipWeapon()
  52.  
  53. local function useSkill(skillName)
  54.     local eventFolder = game:GetService("ReplicatedStorage"):FindFirstChild("Events")
  55.     if eventFolder and eventFolder:FindFirstChild("Skill") then
  56.         eventFolder.Skill:FireServer({ Skill = skillName, Function = "Activate" }, humanoidRootPart.Position, true)
  57.     end
  58. end
  59.  
  60. local function attack()
  61.     while autoFarm do
  62.         local mob = getClosestMob()
  63.         if mob then
  64.             -- โจมตีโดยไม่เข้าใกล้
  65.             local eventFolder = game:GetService("ReplicatedStorage"):FindFirstChild("Events")
  66.             if eventFolder and eventFolder:FindFirstChild("Combat") then
  67.                 eventFolder.Combat:FireServer("Attack")
  68.             end
  69.             useSkill("FlurryOfBlows")
  70.             useSkill("BloodyCut")
  71.             useSkill("Invisibility")
  72.         end
  73.         task.wait(0.5)
  74.     end
  75. end
  76.  
  77. local function stopAutoFarm()
  78.     autoFarm = false
  79.     humanoidRootPart.Anchored = false
  80. end
  81.  
  82. local function enableNoFall()
  83.     runService.Stepped:Connect(function()
  84.         if autoFarm and humanoidRootPart then
  85.             humanoidRootPart.Velocity = Vector3.new(0, 0, 0)
  86.         end
  87.     end)
  88. end
  89.  
  90. enableNoFall()
  91. moveCharacterOutOfRange()
  92.  
  93. userInput.InputBegan:Connect(function(input, gameProcessed)
  94.     if not gameProcessed and input.KeyCode == Enum.KeyCode.Zero then
  95.         stopAutoFarm()
  96.     end
  97. end)
  98.  
  99. attack()
  100.  

captcha