--BROUGHT TO YOU BY RobloxScripter.com!--
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
function getGoal()
local dist, goal = 9e9, nil
for i,v in pairs(workspace.Courts:GetDescendants()) do
if v.Name == "Net" then
local mag = (plr.Character.Torso.Position - v.Position).Magnitude
if dist > mag then
dist = mag; goal = v
end
end
end
return goal, dist
end
function calculateVector()
local goal, dist = getGoal()
local pwr = tonumber(game.Players.LocalPlayer.PlayerGui.BallGui.PowerFrame.ImageLabel.Label.Text)
local vector = nil
if dist > 58 and dist 63 and dist 68 and dist < 74 then
print(dist)
if pwr == 85 then
vector = Vector3.new(0, 65, 0)
end
end
return vector
end
uis.InputBegan:Connect(function(key, gpe)
if not gpe and key.KeyCode == Enum.KeyCode.X then
local vector = calculateVector()
if plr.Character:FindFirstChild("Ball") and vector ~= nil then
local goal, dist = getGoal()
local args = {
[1] = "shoot",
[2] = goal.Position + calculateVector()
}
game:GetService("Players").LocalPlayer.Character.Ball.CSC:FireServer(unpack(args))
end
end
end)