Advertisement
YTBB

Tio's HUB

Mar 30th, 2025
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.37 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local vu = game:GetService("VirtualUser")
  3. local runService = game:GetService("RunService")
  4.  
  5. -- Funzione per trovare l'NPC più vicino
  6. function getClosestNPC()
  7.     local character = player.Character
  8.     if not character then return nil end
  9.  
  10.     local hrp = character:FindFirstChild("HumanoidRootPart")
  11.     if not hrp then return nil end
  12.  
  13.     local closestNPC = nil
  14.     local shortestDistance = math.huge
  15.  
  16.     for _, npc in pairs(workspace.Enemies:GetChildren()) do
  17.         if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  18.             local distance = (hrp.Position - npc.HumanoidRootPart.Position).Magnitude
  19.             if distance < shortestDistance then
  20.                 shortestDistance = distance
  21.                 closestNPC = npc
  22.             end
  23.         end
  24.     end
  25.     return closestNPC
  26. end
  27.  
  28. -- Funzione per attivare l'attacco della spada
  29. function useSwordAttack()
  30.     local character = player.Character
  31.     if not character then return end
  32.  
  33.     local humanoid = character:FindFirstChild("Humanoid")
  34.     if not humanoid then return end
  35.  
  36.     -- Verifica se l'abilità della spada è disponibile e la usa
  37.     -- Supponiamo che l'abilità della spada sia una funzione dell'oggetto spada
  38.     local sword = character:FindFirstChildOfClass("Tool")  -- Assume che la spada sia un Tool
  39.     if sword and sword:IsA("Tool") then
  40.         -- Usa la spada (simulazione dell'attacco)
  41.         sword:Activate()  -- Questo invoca l'abilità della spada automaticamente
  42.     end
  43. end
  44.  
  45. -- Funzione per controllare se il giocatore è in acqua
  46. function isInWater()
  47.     local character = player.Character
  48.     if not character then return false end
  49.  
  50.     local hrp = character:FindFirstChild("HumanoidRootPart")
  51.     if not hrp then return false end
  52.  
  53.     return hrp.Position.Y < 5 -- Se è sotto l'altezza 5, è considerato in acqua
  54. end
  55.  
  56. -- Funzione per teletrasportare il giocatore al nemico più vicino
  57. function teleportToEnemy()
  58.     local target = getClosestNPC()
  59.     if target then
  60.         local character = player.Character
  61.         if not character then return end
  62.  
  63.         local hrp = character:FindFirstChild("HumanoidRootPart")
  64.         if not hrp then return end
  65.  
  66.         hrp.CFrame = target.HumanoidRootPart.CFrame + Vector3.new(0, 5, 0) -- Teletrasporto sopra il nemico
  67.     end
  68. end
  69.  
  70. -- Auto-click (clicca ogni 10ms)
  71. spawn(function()
  72.     while true do
  73.         vu:Button1Down(Vector2.new(0, 0)) -- Simula il click
  74.         task.wait(0.01) -- Aspetta 10ms
  75.     end
  76. end)
  77.  
  78. -- Movimento automatico con gestione dell'acqua e salto
  79. local function startMovement()
  80.     runService.RenderStepped:Connect(function()
  81.         local character = player.Character
  82.         if not character then return end
  83.  
  84.         local humanoid = character:FindFirstChild("Humanoid")
  85.         local hrp = character:FindFirstChild("HumanoidRootPart")
  86.         if not humanoid or not hrp then return end
  87.  
  88.         -- Se il giocatore è in acqua, teletrasportalo
  89.         if isInWater() then
  90.             teleportToEnemy()
  91.         end
  92.  
  93.         local target = getClosestNPC()
  94.        
  95.         if target then
  96.             local enemyPosition = target.HumanoidRootPart.Position
  97.  
  98.             -- Spostati verso il nemico
  99.             if (hrp.Position - enemyPosition).Magnitude > 5 then
  100.                 humanoid:MoveTo(enemyPosition)
  101.             end
  102.            
  103.             -- Se il nemico è vicino, usa la spada
  104.             if (hrp.Position - enemyPosition).Magnitude <= 5 then
  105.                 useSwordAttack()  -- Usa l'attacco della spada quando è vicino
  106.             end
  107.  
  108.             -- Se il nemico è in alto, salta
  109.             if enemyPosition.Y - hrp.Position.Y > 3 then
  110.                 humanoid.Jump = true
  111.             end
  112.         end
  113.     end)
  114. end
  115.  
  116. -- Funzione per rilevare la morte e refreshare il personaggio
  117. local function detectDeath()
  118.     player.CharacterAdded:Connect(function(character)
  119.         task.wait(1) -- Aspetta 1 secondo dopo la morte
  120.         local humanoid = character:WaitForChild("Humanoid")
  121.         local hrp = character:WaitForChild("HumanoidRootPart")
  122.  
  123.         -- Dopo il respawn, premi automaticamente "3"
  124.         task.wait(2) -- Aspetta 2 secondi per assicurarsi che il personaggio sia caricato
  125.     end)
  126. end
  127.  
  128. -- Avvia le funzioni principali
  129. startMovement()
  130. detectDeath()
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement