DefNotScamming

Untitled

Aug 10th, 2025 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.02 KB | Gaming | 0 0
  1. -- ================================================================= --
  2. --                             SERVICES                              --
  3. -- ================================================================= --
  4. local Players = game:GetService("Players")
  5. local RunService = game:GetService("RunService")
  6. local VirtualInputManager = game:GetService("VirtualInputManager")
  7. local Workspace = game:GetService("Workspace")
  8. local UserInputService = game:GetService("UserInputService")
  9.  
  10. -- ================================================================= --
  11. --                           PLAYER VARIABLES                        --
  12. -- ================================================================= --
  13. local player = Players.LocalPlayer
  14. local character = player.Character or player.CharacterAdded:Wait()
  15. local hrp = character:WaitForChild("HumanoidRootPart")
  16. local ballsFolder = Workspace:WaitForChild("Balls")
  17.  
  18. -- ================================================================= --
  19. --                           RADIUS CONFIGURATION                    --
  20. -- ================================================================= --
  21. local baseHitRadius = 35         -- The default radius when auto radius is off
  22. local maxRadius = 100            -- The maximum radius when auto radius is on
  23. local smoothingSpeed = 8         -- Higher value means the radius changes faster
  24. local speedMultiplier = 1.5      -- Adjust this value to change how much speed affects the radius
  25.  
  26. -- ================================================================= --
  27. --                            SPHERE VISUALS                         --
  28. -- ================================================================= --
  29. local sphereTransparency = 0.8
  30. local sphereColor = Color3.fromRGB(255, 0, 0)
  31.  
  32. local sphere = Instance.new("Part")
  33. sphere.Shape = Enum.PartType.Ball
  34. sphere.Anchored = true
  35. sphere.CanCollide = false
  36. sphere.CanTouch = false
  37. sphere.CanQuery = false
  38. sphere.Massless = true
  39. sphere.Material = Enum.Material.Neon
  40. sphere.Color = sphereColor
  41. sphere.Transparency = sphereTransparency
  42. sphere.Size = Vector3.new(baseHitRadius * 2, baseHitRadius * 2, baseHitRadius * 2)
  43. sphere.Parent = Workspace
  44.  
  45. -- ================================================================= --
  46. --                            STATE VARIABLES                        --
  47. -- ================================================================= --
  48. local debounce = false
  49. local autoRadiusEnabled = false
  50. local currentRadius = baseHitRadius
  51.  
  52. -- ================================================================= --
  53. --                           HELPER FUNCTIONS                        --
  54. -- ================================================================= --
  55.  
  56. --- @dev Simulates a key press for the 'F' key.
  57. local function pressF()
  58.     if debounce then return end
  59.     debounce = true
  60.     VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.F, false, game)
  61.     task.wait(0.03)
  62.     VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.F, false, game)
  63.     task.wait(0.15)
  64.     debounce = false
  65. end
  66.  
  67. --- @dev Checks if the player's character has a 'Highlight' instance.
  68. --- @return boolean True if highlighted, false otherwise.
  69. local function isHighlighted()
  70.    if character then
  71.        for _, child in ipairs(character:GetChildren()) do
  72.            if child:IsA("Highlight") then
  73.                return true
  74.            end
  75.        end
  76.    end
  77.    return false
  78. end
  79.  
  80. -- ================================================================= --
  81. --                           EVENT LISTENERS                         --
  82. -- ================================================================= --
  83.  
  84. -- Handle character respawns to ensure the script has the correct references.
  85. player.CharacterAdded:Connect(function(char)
  86.    character = char
  87.    hrp = character:WaitForChild("HumanoidRootPart")
  88. end)
  89.  
  90. -- Main game loop that runs every frame.
  91. RunService.RenderStepped:Connect(function(dt)
  92.    if not (hrp and hrp.Parent) then return end
  93.  
  94.    local closestBall = nil
  95.    local closestDist = math.huge
  96.  
  97.    -- Find the closest ball in the 'Balls' folder.
  98.    for _, ball in pairs(ballsFolder:GetChildren()) do
  99.        if ball:IsA("BasePart") then
  100.            local dist = (ball.Position - hrp.Position).Magnitude
  101.            if dist < closestDist then
  102.                closestDist = dist
  103.                closestBall = ball
  104.            end
  105.        end
  106.    end
  107.  
  108.    -- If no balls are found, hide the sphere and exit.
  109.    if not closestBall then
  110.        sphere.CFrame = hrp.CFrame + Vector3.new(0, -1000, 0) -- hide sphere
  111.        return
  112.    end
  113.  
  114.    -- Calculate the target radius based on whether auto radius is enabled and the ball's speed.
  115.     local targetRadius = baseHitRadius
  116.     if autoRadiusEnabled then
  117.         local ballSpeed = closestBall.Velocity.Magnitude
  118.         -- The radius is proportional to the ball's speed, clamped between the base and max values.
  119.        -- 'speedMultiplier' can be adjusted to make the radius change more or less aggressively.
  120.        targetRadius = math.clamp(ballSpeed * speedMultiplier, baseHitRadius, maxRadius)
  121.    end
  122.  
  123.    -- Smoothly change the current radius towards the target radius.
  124.    currentRadius = currentRadius + (targetRadius - currentRadius) * math.clamp(dt * smoothingSpeed, 0, 1)
  125.  
  126.    -- Update the sphere's size and position to match the closest ball.
  127.     sphere.Size = Vector3.new(currentRadius * 2, currentRadius * 2, currentRadius * 2)
  128.     sphere.CFrame = closestBall.CFrame
  129.  
  130.     -- Check if conditions are met to press 'F'.
  131.     if isHighlighted() and closestDist <= currentRadius then
  132.         pressF()
  133.     end
  134. end)
  135.  
  136. -- Toggle the auto radius feature with the 'R' key.
  137. UserInputService.InputBegan:Connect(function(input)
  138.     if input.KeyCode == Enum.KeyCode.R then
  139.         autoRadiusEnabled = not autoRadiusEnabled
  140.         print("Auto Radius Enabled:", autoRadiusEnabled)
  141.         -- Reset the radius immediately when toggled off for a cleaner feel
  142.         if not autoRadiusEnabled then
  143.             currentRadius = baseHitRadius
  144.         end
  145.     end
  146. end)
  147.  
Tags: #autoparry
Advertisement
Add Comment
Please, Sign In to add comment