My soccer ball used to work just fine, now it doesn’t even work anymore? When I try hitting it, it just starts spinning one way slowly? I’m not even sure what’s going on. There’s no errors, and when I try to print lines it shows that everything works fine?
(Client-script inside a tool.)
local function onTouched(hitPart: BasePart)
if hitPart.Name ~= "Ball" or not isKicking then
return
end
ToolManager:setNetworkOwner(hitPart) -- Module function, sets NetworkOwner of the ball to the player.
hitPart:ApplyImpulse(humanoidRootPart.CFrame.LookVector * power + humanoidRootPart.CFrame.UpVector * height)
print("applied")
local ballPosition = hitPart.Position + Vector3.new(0, humanoidRootPart.Position.Y - hitPart.Position.Y, 0)
local dotProduct = humanoidRootPart.CFrame.LookVector:Dot(ballPosition - humanoidRootPart.Position)
local torsoOrientation = math.acos(dotProduct / (ballPosition - humanoidRootPart.Position).Magnitude)
if torsoOrientation > math.rad(18) and (hitPart.Position - leftArm.Position).Magnitude < (hitPart.Position - rightArm.Position).Magnitude then
task.spawn(function()
for curveAmount = 1, power * .3 do
hitPart:ApplyImpulse(-humanoidRootPart.CFrame.RightVector) -- Apply curve movement
task.wait()
end
end)
hitPart:ApplyAngularImpulse(Vector3.new(0, .3 * power, 0)) -- Apply spin to the ball
elseif torsoOrientation > math.rad(45) and (hitPart.Position - rightArm.Position).Magnitude < (hitPart.Position - leftArm.Position).Magnitude then
task.spawn(function()
for curveAmount = 1, power * .3 do
hitPart:ApplyImpulse(humanoidRootPart.CFrame.RightVector) -- Apply curve movement
task.wait()
end
end)
hitPart:ApplyAngularImpulse(Vector3.new(0, .3 * -power, 0)) -- Apply spin to the ball
end
isKicking = false
resetPower()
end
rightLeg.Touched:Connect(onTouched)