0% found this document useful (0 votes)
613 views2 pages

Auto Parry

This script monitors proximity between balls in a game workspace and the local player's character. It calculates prediction times for ball collisions, displays an indicator near monitored balls, and triggers button presses when balls are close enough to the player, allowing the player to parry attacks. The script connects to the RunService heartbeat to regularly check ball proximity.

Uploaded by

chickuwapawawawa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
613 views2 pages

Auto Parry

This script monitors proximity between balls in a game workspace and the local player's character. It calculates prediction times for ball collisions, displays an indicator near monitored balls, and triggers button presses when balls are close enough to the player, allowing the player to parry attacks. The script connects to the RunService heartbeat to regularly check ball proximity.

Uploaded by

chickuwapawawawa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

local workspace = game:GetService("Workspace")

local players = game:GetService("Players")


local runService = game:GetService("RunService")

local ballFolder = workspace.Balls


local indicatorPart = Instance.new("Part")
indicatorPart.Size = Vector3.new(5, 5, 5)
indicatorPart.Anchored = true
indicatorPart.CanCollide = false
indicatorPart.Transparency = 1
indicatorPart.BrickColor = BrickColor.new("Bright red")
indicatorPart.Parent = workspace

local lastBallPressed = nil


local isKeyPressed = false

local function calculatePredictionTime(ball, player)


if player.Character and player.Character:FindFirstChild("HumanoidRootPart")
then
local rootPart = player.Character.HumanoidRootPart
local relativePosition = ball.Position - rootPart.Position
local velocity = ball.Velocity + rootPart.Velocity
local a = (ball.Size.magnitude / 2)
local b = relativePosition.magnitude
local c = math.sqrt(a * a + b * b)
local timeToCollision = (c - a) / velocity.magnitude
return timeToCollision
end
return math.huge
end

local function updateIndicatorPosition(ball)


indicatorPart.Position = ball.Position
end

local function checkProximityToPlayer(ball, player)


local predictionTime = calculatePredictionTime(ball, player)
local realBallAttribute = ball:GetAttribute("realBall")
local target = ball:GetAttribute("target")

local ballSpeedThreshold = math.max(0.4, 0.6 - ball.Velocity.magnitude * 0.01)

if predictionTime <= ballSpeedThreshold and realBallAttribute == true and


target == player.Name and not isKeyPressed then
game:GetService("ReplicatedStorage").Remotes.ParryButtonPress:Fire()
wait(0.005)
game:GetService("ReplicatedStorage").Remotes.ParryButtonPress:Fire()
lastBallPressed = ball
isKeyPressed = true
elseif lastBallPressed == ball and (predictionTime > ballSpeedThreshold or
realBallAttribute ~= true or target ~= player.Name) then
isKeyPressed = false
end
end

local function checkBallsProximity()


local player = players.LocalPlayer
if player then
for _, ball in pairs(ballFolder:GetChildren()) do
checkProximityToPlayer(ball, player)
updateIndicatorPosition(ball)
end
end
end

runService.Heartbeat:Connect(checkBallsProximity)

print("Script ran without errors")

You might also like