chargingType = (input.UserInputType == Enum.UserInputType.MouseButton1) and "Pass" or "Shoot"
applyGradient((chargingType == "Pass") and "PassGradient" or "ShootGradient")
resolveUIRefs()
if shootBar then shootBar.Visible = true end
chargingHitbox = HitboxManager.CreateHitbox("InFrontOfLegs")
if not chargingHitbox then return end
chargingHitbox.Transparency = 1
chargingHitbox.BrickColor = BrickColor.Red()
chargingHitbox.Material = Enum.Material.ForceField
local allBalls = {}
for _, pf in ipairs(ballsFolder:GetChildren()) do
for _, b in ipairs(pf:GetChildren()) do
if b:IsA("BasePart") and b.Name == "Ball" then
table.insert(allBalls, b)
end
end
end
local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = allBalls
task.spawn(function()
while charging do
if not character.Parent or not rootPart.Parent then break end
if not chargingHitbox or not chargingHitbox.Parent then break end
chargingHitbox.CFrame = rootPart.CFrame * HitboxPresets.InFrontOfLegs.Offset
local parts = HitboxManager.GetPartsInHitbox(chargingHitbox, params)
local found = nil
for _, p in ipairs(parts) do
if p:IsA("BasePart") and p.Name == "Ball" then
found = p
break
end
end
preTargetBall = found
chargingHitbox.Transparency = 1
RunService.Heartbeat:Wait()
end
if chargingHitbox and chargingHitbox.Parent then
HitboxManager.DestroyHitbox(chargingHitbox)
chargingHitbox = nil
end
end)
local now = tick()
if clickWindowStart == 0 or now - clickWindowStart > 1 then
clickWindowStart = now
shootClicks = 0
end
shootClicks += 1
chargingHitbox.Transparency = 1
if shootClicks >= 5 then
charging = false
chargingType = nil
resetShootBar()
if animTracks.ChargeShot then
animTracks.ChargeShot:Stop()
animTracks.ChargeShot:Play()
end
task.delay(1.5, function()
shootClicks = 0
clickWindowStart = 0
end)
if preTargetBall then
local rv = preTargetBall.Velocity
local power = 1
if Curve == "Left" then
local cc = Instance.new("BodyForce", preTargetBall)
cc.Force = -rv * power
game:GetService("Debris"):AddItem(cc, 5)
elseif Curve == "Right" then
local cc = Instance.new("BodyForce", preTargetBall)
cc.Force = rv * power
game:GetService("Debris"):AddItem(cc, 5)
end
end
ShootBallEvent:FireServer(chargingType == "Shoot")
end
end