Auto Parry multiple balls
Key RequiredUniversal

Auto Parry multiple balls

Universal ScriptJustShareJustShare 4.5K views 22 executesUpdated Mar 4, 2025
0.0/ 5(1 votes)
010% Positive
Lua Script•186 lines (6677 chars)
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local VirtualInputManager = game:GetService("VirtualInputManager")
local Player = Players.LocalPlayer
local previousVelocities = {}
local previousPlayerPosition = nil
local hitboxLine = nil
local function DrawTemporaryHitboxLine(startPos, endPos)
	local dist = (startPos - endPos).Magnitude
	local part = Instance.new("Part")
	part.Size = Vector3.new(0.2, 0.2, dist)
	part.CFrame = CFrame.new(startPos, endPos) * CFrame.new(0, 0, -dist/2)
	part.Anchored = true
	part.CanCollide = false
	part.Color = Color3.new(1, 0, 0)
	part.Material = Enum.Material.Neon
	part.Transparency = 0.3
	part.Parent = workspace
	task.delay(0.05, function() part:Destroy() end)
end
local function UpdateVelocityLabel(ball, speed)
	local label = ball:FindFirstChild("VelocityLabel")
	if not label then
		label = Instance.new("BillboardGui")
		label.Name = "VelocityLabel"
		label.Adornee = ball
		label.Size = UDim2.new(0,120,0,50)
		label.StudsOffset = Vector3.new(0,3,0)
		label.Parent = ball
		local txt = Instance.new("TextLabel")
		txt.Size = UDim2.new(1,0,1,0)
		txt.BackgroundTransparency = 1
		txt.TextColor3 = Color3.new(1,1,1)
		txt.TextStrokeTransparency = 0
		txt.Font = Enum.Font.SourceSansBold
		txt.TextScaled = true
		txt.Parent = label
	end
	label.TextLabel.Text = string.format("Velocity: %.2f", speed)
end
local function ResetConnectionForBall(ball)
	local conn = ball:GetAttribute("ParryConn")
	if conn then
		conn:Disconnect()
		ball:SetAttribute("ParryConn", nil)
	end
end
workspace.Balls.ChildAdded:Connect(function(child)
	if Player.Character and Player.Character.Parent and Player.Character.Parent.Name == "Alive" and child:GetAttribute("realBall") then
		ResetConnectionForBall(child)
		local conn = child:GetAttributeChangedSignal("target"):Connect(function()
			child:SetAttribute("parried", false)
		end)
		child:SetAttribute("ParryConn", conn)
	end
end)
workspace.TrainingBalls.ChildAdded:Connect(function(child)
	if Player.Character and Player.Character.Parent and Player.Character.Parent.Name ~= "Alive" and child:GetAttribute("realBall") then
		ResetConnectionForBall(child)
		local conn = child:GetAttributeChangedSignal("target"):Connect(function()
			child:SetAttribute("parried", false)
		end)
		child:SetAttribute("ParryConn", conn)
	end
end)
RunService.PreSimulation:Connect(function()
	local character = Player.Character
	if not character then return end
	local hrp = character:FindFirstChild("HumanoidRootPart")
	if not hrp then return end
	local ballFolder = (character.Parent and character.Parent.Name == "Alive") and workspace.Balls or workspace.TrainingBalls
	local humanoid = character:FindFirstChild("Humanoid")
	local parryBalls = {}
	local closestBall, closestPredictedTime = nil, math.huge
	for _, ball in ipairs(ballFolder:GetChildren()) do
		if ball:GetAttribute("realBall") then
			DrawTemporaryHitboxLine(hrp.Position, ball.Position)
			local currentVelocity = ball.zoomies.VectorVelocity
			local speed = currentVelocity.Magnitude
			local ballDistance = (hrp.Position - ball.Position).Magnitude
			UpdateVelocityLabel(ball, speed)
			local prevVel = previousVelocities[ball]
			local curvature = 0
			if prevVel and speed > 0 and prevVel.Magnitude > 0 then
				local dot = math.clamp(prevVel.Unit:Dot(currentVelocity.Unit), -1, 1)
				curvature = math.acos(dot)
			end
			previousVelocities[ball] = currentVelocity
			local baseThreshold = (ballFolder == workspace.TrainingBalls) and 0.7 or 0.55
			if curvature > math.rad(10) then
				baseThreshold = baseThreshold + 0.1
			end
			local effectiveThreshold
			if speed <= 50 then
				if speed < 10 then
					effectiveThreshold = baseThreshold * 6
				else
					effectiveThreshold = baseThreshold * (6 - (3 * (speed - 10) / 40))
				end
			elseif speed <= 100 then
				effectiveThreshold = baseThreshold * 1.2
			elseif speed <= 200 then
				effectiveThreshold = baseThreshold * 0.8
			else
				effectiveThreshold = baseThreshold * 0.6
			end
			if speed > 100 then
				effectiveThreshold = effectiveThreshold + ((speed - 100) / 150)
			end
			local otherPlayerNearby = false
			for _, other in ipairs(Players:GetPlayers()) do
				if other ~= Player and other.Character and other.Character:FindFirstChild("HumanoidRootPart") then
					local otherHrp = other.Character.HumanoidRootPart
					if (hrp.Position - otherHrp.Position).Magnitude < 20 then
						otherPlayerNearby = true
						break
					end
				end
			end
			if otherPlayerNearby then
				effectiveThreshold = effectiveThreshold + 0.2
			end
			local direction = (ball.Position - hrp.Position).Unit
			local ballApproachSpeed = currentVelocity:Dot(direction)
			local playerApproachSpeed = hrp.Velocity:Dot(direction)
			local relativeSpeed = ballApproachSpeed - playerApproachSpeed
			if relativeSpeed <= 0 then
				relativeSpeed = currentVelocity.Magnitude
			end
			local predictedTime = ballDistance / relativeSpeed
			local dynamicThreshold
			if speed < 10 then
				dynamicThreshold = 15
			elseif speed < 100 then
				dynamicThreshold = 15 + ((speed - 10) / 90) * (50 - 15)
			else
				dynamicThreshold = 50
			end
			if ball:GetAttribute("target") == Player.Name and not ball:GetAttribute("parried") and speed > 0 then
				if ballDistance <= 15 then
					table.insert(parryBalls, ball)
				elseif ballDistance <= dynamicThreshold and predictedTime <= effectiveThreshold then
					table.insert(parryBalls, ball)
				end
			end
			if ball:GetAttribute("target") == Player.Name and not ball:GetAttribute("parried") then
				if predictedTime < closestPredictedTime then
					closestPredictedTime = predictedTime
					closestBall = ball
				end
			end
		end
	end
	previousPlayerPosition = hrp.Position
	for i, b in ipairs(parryBalls) do
		task.spawn(function()
			VirtualInputManager:SendMouseButtonEvent(0,0,0,true,game,0)
			b:SetAttribute("parried", true)
			task.wait(0.01)
		end)
	end
	if character.Parent and character.Parent.Name == "Alive" and humanoid then
		local bv = hrp:FindFirstChild("AutoMoveVelocity")
		if not bv then
			bv = Instance.new("BodyVelocity")
			bv.Name = "AutoMoveVelocity"
			bv.MaxForce = Vector3.new(1e5,0,1e5)
			bv.P = 1000
			bv.Parent = hrp
		end
		if closestBall then
			local dist = (hrp.Position - closestBall.Position).Magnitude
			if dist > 15 then
				bv.Velocity = (closestBall.Position - hrp.Position).Unit * (humanoid.WalkSpeed or 16)
			else
				bv.Velocity = Vector3.new(0,0,0)
			end
			hrp.CFrame = CFrame.new(hrp.Position, closestBall.Position)
		else
			bv.Velocity = Vector3.new(0,0,0)
		end
	else
		local bv = hrp:FindFirstChild("AutoMoveVelocity")
		if bv then bv:Destroy() end
	end
end)

Features & Information

If you want it to be more responsive, you can set it manually to set the Threshold
#Free#OpenSource

Community Comments (3)

tekxshixtekxshixMar 4, 2025(edited)

keeps running after the ball, how do you turn this off?

BigBlue_ScripterBigBlue_ScripterMar 4, 2025(edited)

freezing most * script

CatullahCatullahMar 4, 2025(edited)

its mid

More Scripts for Universal Scripts