Elisonpp

Blade ball

Dec 9th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. -- LocalScript inside StarterPlayer -> StarterPlayerScripts
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  6. local ball = workspace:WaitForChild("Ball") -- Assuming the ball is named "Ball" in the workspace
  7.  
  8. local maxDistance = 10 -- Maximum distance for auto-press to trigger
  9. local uis = game:GetService("UserInputService")
  10. local rs = game:GetService("RunService")
  11.  
  12. -- Function to simulate key press (F key)
  13. local function simulateKeyPress()
  14. -- Create a new input object simulating an F key press
  15. local inputObject = Instance.new("InputObject")
  16. inputObject.UserInputType = Enum.UserInputType.Keyboard
  17. inputObject.KeyCode = Enum.KeyCode.F
  18.  
  19. -- Fire the input began event (key down)
  20. uis.InputBegan:Fire(inputObject, false)
  21. end
  22.  
  23. -- Continuous check every frame
  24. rs.RenderStepped:Connect(function()
  25. -- Calculate the distance between the player and the ball
  26. local distance = (humanoidRootPart.Position - ball.Position).Magnitude
  27.  
  28. -- Check if the ball is within the range
  29. if distance <= maxDistance then
  30. simulateKeyPress() -- Simulate the F key press
  31. end
  32. end)
Advertisement
Add Comment
Please, Sign In to add comment