rightLeg.Touched:Connect(function(otherPart: BasePart)
if otherPart.Name ~= "Ball" or not isKicking or ToolController:getCurrentLeg() ~= "Right" then
return
end
isKicking = false
ReplicatedStorage.RemoteEvents.UpdateOwner:FireServer(otherPart)
local kickVelocity = Instance.new("BodyVelocity")
kickVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
kickVelocity.Velocity = humanoidRootPart.CFrame.LookVector * power + humanoidRootPart.CFrame.UpVector * (power * .5)
kickVelocity.Parent = otherPart
Debris:AddItem(kickVelocity, .3)
local ballPosition = otherPart.Position + Vector3.new(0, humanoidRootPart.Position.Y - otherPart.Position.Y, 0)
local dotProduct = humanoidRootPart.CFrame.lookVector:Dot(ballPosition - humanoidRootPart.Position)
local torsoAngle = math.acos(dotProduct / (ballPosition - humanoidRootPart.Position).Magnitude)
if torsoAngle > math.rad(30) and (otherPart.Position - leftArm.Position).Magnitude < (otherPart.Position - rightArm.Position).Magnitude then
local curveForce = Instance.new("BodyForce")
curveForce.Force = humanoidRootPart.CFrame.RightVector * -150
curveForce.Parent = otherPart
local curveAngularVelocity = Instance.new("BodyAngularVelocity")
curveAngularVelocity.MaxTorque = Vector3.new(0, math.huge, 0)
curveAngularVelocity.AngularVelocity = Vector3.new(0, power * .7, 0)
curveAngularVelocity.Parent = otherPart
Debris:AddItem(curveForce, power/MAXIMUM_POWER)
Debris:AddItem(curveAngularVelocity, power/MAXIMUM_POWER)
elseif torsoAngle > math.rad(45) and (otherPart.Position - leftArm.Position).Magnitude > (otherPart.Position - rightArm.Position).Magnitude then
local curveForce = Instance.new("BodyForce")
curveForce.Force = humanoidRootPart.CFrame.RightVector * 150
curveForce.Parent = otherPart
local curveAngularVelocity = Instance.new("BodyAngularVelocity")
curveAngularVelocity.MaxTorque = Vector3.new(0, math.huge, 0)
curveAngularVelocity.AngularVelocity = Vector3.new(0, -power * .7, 0)
curveAngularVelocity.Parent = otherPart
Debris:AddItem(curveForce, power/MAXIMUM_POWER)
Debris:AddItem(curveAngularVelocity, power/MAXIMUM_POWER)
end
end)
leftLeg.Touched:Connect(function(otherPart: BasePart)
if otherPart.Name ~= "Ball" or not isKicking or ToolController:getCurrentLeg() ~= "Left" then
return
end
isKicking = false
ReplicatedStorage.RemoteEvents.UpdateOwner:FireServer(otherPart)
local kickVelocity = Instance.new("BodyVelocity")
kickVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
kickVelocity.Velocity = humanoidRootPart.CFrame.LookVector * power + humanoidRootPart.CFrame.UpVector * (power * .5)
kickVelocity.Parent = otherPart
Debris:AddItem(kickVelocity, .3)
local ballPosition = otherPart.Position + Vector3.new(0, humanoidRootPart.Position.Y - otherPart.Position.Y, 0)
local dotProduct = humanoidRootPart.CFrame.lookVector:Dot(ballPosition - humanoidRootPart.Position)
local torsoAngle = math.acos(dotProduct / (ballPosition - humanoidRootPart.Position).Magnitude)
if torsoAngle > math.rad(30) and (otherPart.Position - leftArm.Position).Magnitude < (otherPart.Position - rightArm.Position).Magnitude then
local curveForce = Instance.new("BodyForce")
curveForce.Force = humanoidRootPart.CFrame.RightVector * -150
curveForce.Parent = otherPart
local curveAngularVelocity = Instance.new("BodyAngularVelocity")
curveAngularVelocity.MaxTorque = Vector3.new(0, math.huge, 0)
curveAngularVelocity.AngularVelocity = Vector3.new(0, power * .7, 0)
curveAngularVelocity.Parent = otherPart
Debris:AddItem(curveForce, power/MAXIMUM_POWER)
Debris:AddItem(curveAngularVelocity, power/MAXIMUM_POWER)
elseif torsoAngle > math.rad(45) and (otherPart.Position - leftArm.Position).Magnitude > (otherPart.Position - rightArm.Position).Magnitude then
local curveForce = Instance.new("BodyForce")
curveForce.Force = humanoidRootPart.CFrame.RightVector * 150
curveForce.Parent = otherPart
local curveAngularVelocity = Instance.new("BodyAngularVelocity")
curveAngularVelocity.MaxTorque = Vector3.new(0, math.huge, 0)
curveAngularVelocity.AngularVelocity = Vector3.new(0, -power * .7, 0)
curveAngularVelocity.Parent = otherPart
Debris:AddItem(curveForce, power/MAXIMUM_POWER)
Debris:AddItem(curveAngularVelocity, power/MAXIMUM_POWER)
end
end)
Why does my ball randomly rise mid-air after I shoot the soccer ball? If it helps, there is a bodyForce in the ball with vector3.new(0, 700, 0) to simulate a low gravity effect. I made something similiar to this and this never happened before.