portalfan_4324

Rivals Aimbot! {Updated)

Nov 16th, 2024 (edited)
10,342
3
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.48 KB | None | 3 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3. local UserInputService = game:GetService("UserInputService")
  4. local Workspace = game:GetService("Workspace")
  5. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  6.  
  7. local Camera = Workspace.CurrentCamera
  8. local LocalPlayer = Players.LocalPlayer
  9.  
  10. -- Feature state
  11. local silentAimActive = false
  12. local espActive = false
  13. local espList = {}
  14.  
  15. -- UI Setup
  16. local ScreenGui = Instance.new("ScreenGui")
  17. ScreenGui.Name = "ControlPanel"
  18. ScreenGui.ResetOnSpawn = false
  19. ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")
  20.  
  21. local function createToggleButton(name, position, callback)
  22.     local button = Instance.new("TextButton")
  23.     button.Size = UDim2.new(0, 150, 0, 40)
  24.     button.Position = position
  25.     button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  26.     button.TextColor3 = Color3.fromRGB(255, 255, 255)
  27.     button.TextSize = 18
  28.     button.Font = Enum.Font.SourceSansBold
  29.     button.Text = name .. ": OFF"
  30.     button.Parent = ScreenGui
  31.  
  32.     local isOn = false
  33.     button.MouseButton1Click:Connect(function()
  34.         isOn = not isOn
  35.         button.Text = name .. ": " .. (isOn and "ON" or "OFF")
  36.         callback(isOn)
  37.     end)
  38. end
  39.  
  40. -- Toggle Buttons
  41. createToggleButton("Silent Aim", UDim2.new(0, 20, 0, 100), function(state)
  42.     silentAimActive = state
  43. end)
  44.  
  45. createToggleButton("ESP", UDim2.new(0, 20, 0, 150), function(state)
  46.     espActive = state
  47.  
  48.     if not state then
  49.         -- Hide all ESP immediately
  50.         for _, box in pairs(espList) do
  51.             if box and box.drawing then
  52.                 box.drawing.Visible = false
  53.             end
  54.         end
  55.     end
  56. end)
  57.  
  58. -- Nearest Head
  59. local function getNearestHead()
  60.     if not LocalPlayer.Character or not LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then return nil end
  61.     local closest = nil
  62.     local shortest = math.huge
  63.  
  64.     for _, player in pairs(Players:GetPlayers()) do
  65.         if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  66.             local dist = (player.Character.HumanoidRootPart.Position - LocalPlayer.Character.HumanoidRootPart.Position).Magnitude
  67.             if dist < shortest then
  68.                 shortest = dist
  69.                 closest = player
  70.             end
  71.         end
  72.     end
  73.  
  74.     if closest and closest.Character and closest.Character:FindFirstChild("Head") then
  75.         return closest.Character.Head
  76.     end
  77.  
  78.     return nil
  79. end
  80.  
  81. -- Silent Aim
  82. UserInputService.InputBegan:Connect(function(input)
  83.     if input.UserInputType == Enum.UserInputType.MouseButton1 and silentAimActive then
  84.         local target = getNearestHead()
  85.         if target then
  86.             Camera.CFrame = CFrame.new(Camera.CFrame.Position, target.Position)
  87.             ReplicatedStorage.Remotes.Attack:FireServer(target)
  88.         end
  89.     end
  90. end)
  91.  
  92. -- Setup ESP
  93. local function createESP(player)
  94.     if player == LocalPlayer then return end
  95.  
  96.     local box = Drawing.new("Quad")
  97.     box.Thickness = 2
  98.     box.Color = Color3.fromRGB(0, 0, 255)
  99.     box.Transparency = 1
  100.     box.Visible = false
  101.  
  102.     espList[player] = {
  103.         drawing = box,
  104.         connection = nil
  105.     }
  106.  
  107.     -- Clean up if player leaves
  108.     player.AncestryChanged:Connect(function()
  109.         if not player:IsDescendantOf(game) and espList[player] then
  110.             box:Remove()
  111.             espList[player] = nil
  112.         end
  113.     end)
  114. end
  115.  
  116. -- Add ESP to all players
  117. for _, player in pairs(Players:GetPlayers()) do
  118.     createESP(player)
  119. end
  120.  
  121. -- Player joins
  122. Players.PlayerAdded:Connect(function(player)
  123.     createESP(player)
  124. end)
  125.  
  126. -- Player leaves
  127. Players.PlayerRemoving:Connect(function(player)
  128.     if espList[player] then
  129.         espList[player].drawing:Remove()
  130.         espList[player] = nil
  131.     end
  132. end)
  133.  
  134. -- Main ESP Loop
  135. RunService.RenderStepped:Connect(function()
  136.     for player, data in pairs(espList) do
  137.         local box = data.drawing
  138.         if espActive and player.Character and player.Character:FindFirstChild("HumanoidRootPart") and player.Character:FindFirstChild("Head") then
  139.             local root = player.Character.HumanoidRootPart
  140.             local head = player.Character.Head
  141.  
  142.             local rootPos, onScreen1 = Camera:WorldToViewportPoint(root.Position)
  143.             local headPos, onScreen2 = Camera:WorldToViewportPoint(head.Position + Vector3.new(0, 0.5, 0))
  144.  
  145.             if onScreen1 and onScreen2 then
  146.                 box.PointA = Vector2.new(rootPos.X - 15, rootPos.Y + 30)
  147.                 box.PointB = Vector2.new(rootPos.X + 15, rootPos.Y + 30)
  148.                 box.PointC = Vector2.new(headPos.X + 15, headPos.Y)
  149.                 box.PointD = Vector2.new(headPos.X - 15, headPos.Y)
  150.                 box.Visible = true
  151.             else
  152.                 box.Visible = false
  153.             end
  154.         else
  155.             box.Visible = false
  156.         end
  157.     end
  158. end)
  159.  
  160. print("Silent Aim + ESP UI loaded with clean ESP toggle.")
Advertisement
Comments
Add Comment
Please, Sign In to add comment