Advertisement
PC55654

dwad

Oct 17th, 2024 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.79 KB | Source Code | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local player = game.Players.LocalPlayer
  3. local VirtualInputManager = game:GetService("VirtualInputManager")
  4. local teleportService = game:GetService("TeleportService")
  5. local placeId = game.PlaceId -- Automatically gets the current game's Place ID
  6. local jobId = game.JobId -- Gets the unique ID of the current server
  7.  
  8. -- Function to send Roblox notifications
  9. local function sendNotification(title, text)
  10.     game:GetService("StarterGui"):SetCore("SendNotification", {
  11.         Title = title;
  12.         Text = text;
  13.         Duration = 2; -- Duration for the notification
  14.     })
  15. end
  16.  
  17. sendNotification("Status", "Loading Character")
  18. wait(1)
  19.  
  20. local kenHakiActivated = false -- Flag to check if Ken Haki is activated
  21. local soldier -- Variable to store the selected soldier
  22.  
  23. -- Function to get a random Military Soldier
  24. local function getRandomSoldier()
  25.     local militarySoldiers = {}
  26.     local enemiesFolder = workspace:WaitForChild("Enemies")
  27.     for _, enemy in ipairs(enemiesFolder:GetChildren()) do
  28.         if enemy:IsA("Model") and enemy.Name == "Military Soldier" and enemy:FindFirstChild("HumanoidRootPart") then
  29.             table.insert(militarySoldiers, enemy)
  30.         end
  31.     end
  32.     if #militarySoldiers > 0 then
  33.         return militarySoldiers[math.random(1, #militarySoldiers)]
  34.     end
  35.     return nil
  36. end
  37.  
  38. -- Function to tween to the selected soldier
  39. local function tweenToSoldier(soldier)
  40.     local humanoidRootPart = workspace.Characters[player.Name].HumanoidRootPart
  41.     if soldier and soldier:FindFirstChild("HumanoidRootPart") then
  42.         local targetPosition = soldier.HumanoidRootPart.Position + Vector3.new(0, 3, 0) -- Adjust the height if needed
  43.         local targetCFrame = CFrame.new(targetPosition) -- Create a CFrame for proper orientation
  44.         local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
  45.         local tween = TweenService:Create(humanoidRootPart, tweenInfo, {CFrame = targetCFrame})
  46.  
  47.         tween:Play()
  48.         tween.Completed:Wait() -- Wait for the tween to complete
  49.     else
  50.         warn("Soldier not found or does not have a HumanoidRootPart.")
  51.     end
  52. end
  53.  
  54. -- Function to simulate pressing the "E" key
  55. local function pressE()
  56.     sendNotification("Status", "Enabling Ken Haki")
  57.     wait(1)
  58.     VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.E, false, game)
  59.     wait(0.1) -- Small delay to simulate key press duration
  60.     VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.E, false, game)
  61.     sendNotification("Status", "Ken Haki Enabled")
  62.     wait(0.2)
  63.     sendNotification("Status", "Getting Mob")
  64. end
  65.  
  66. -- Function to rejoin the same server
  67. local function rejoinServer()
  68.     if jobId ~= "" then
  69.         teleportService:TeleportToPlaceInstance(placeId, jobId)
  70.     else
  71.         warn("Failed to retrieve the current server JobId.")
  72.     end
  73. end
  74.  
  75. -- Function to destroy all Lava parts in the specified location
  76. local function destroyLavaParts()
  77.     local magma = workspace:FindFirstChild("Map") and workspace.Map:FindFirstChild("Magma")
  78.     if magma then
  79.         for _, model in ipairs(magma:GetChildren()) do
  80.             if model:IsA("Model") then
  81.                 for _, part in ipairs(model:GetChildren()) do
  82.                     if part:IsA("BasePart") and part.Name == "Lava" then
  83.                         part:Destroy()
  84.                     end
  85.                 end
  86.             end
  87.         end
  88.     else
  89.         warn("Magma folder not found in Map.")
  90.     end
  91. end
  92.  
  93. -- Simulate a click at the specified screen position (288, 152)
  94. local function simulateClickAtPosition(x, y)
  95.     VirtualInputManager:SendMouseButtonEvent(x, y, 0, true, game, 0) -- Simulate mouse down
  96.     wait(0.1) -- Wait for a short duration to simulate click
  97.     VirtualInputManager:SendMouseButtonEvent(x, y, 0, false, game, 0) -- Simulate mouse up
  98.     sendNotification("Status", "Character Loaded")
  99. end
  100.  
  101. -- Main loop
  102. while true do
  103.     -- Wait until the character is in the Characters folder
  104.     local characterName = player.Name
  105.     while not workspace.Characters:FindFirstChild(characterName) do
  106.         simulateClickAtPosition(557, 318) -- Click at the position to load character
  107.         sendNotification("Status", "Loading Character Clicking Team") -- Notification for loading character
  108.         wait(1) -- Wait before checking again to avoid spamming clicks
  109.     end
  110.  
  111.     local humanoid = workspace.Characters[characterName]:WaitForChild("Humanoid") -- Ensure humanoid is available
  112.     local humanoidRootPart = workspace.Characters[characterName]:WaitForChild("HumanoidRootPart") -- Ensure HumanoidRootPart is available
  113.  
  114.     -- Debug print to check current health
  115.     print("Current Health: ", humanoid.Health)
  116.  
  117.     if humanoid.Health < 12700 then -- Check if health is under 12k
  118.         warn("Health is below 12000. Rejoining server...")
  119.         rejoinServer() -- Rejoin the server if health is too low
  120.         return -- Exit the loop to prevent further execution
  121.     end
  122.  
  123.     if not kenHakiActivated then
  124.         wait(2) -- Wait for 2 seconds after the character is loaded
  125.         pressE() -- Simulate pressing "E" to activate Ken Haki
  126.         kenHakiActivated = true -- Set the flag to true after the first press
  127.         wait(2) -- Wait for 2 seconds after pressing "E"
  128.        
  129.         destroyLavaParts() -- Destroy all parts named "Lava" in specified location
  130.        
  131.         soldier = getRandomSoldier() -- Get a random soldier
  132.         if soldier then
  133.             tweenToSoldier(soldier) -- Tween to the selected soldier
  134.         else
  135.             warn("No Military Soldiers found.")
  136.         end
  137.     else
  138.         -- Tween to the already selected soldier
  139.         if soldier then
  140.             tweenToSoldier(soldier)
  141.         end
  142.     end
  143.  
  144.     wait(3) -- Wait before looping again
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement