Soccer ball doesn't even move?!?

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)
1 Like

Have you tried adjusting the math? Since there seem to be no errors, and debugging shows nothing wrong, maybe the math needs fixing?

1 Like
hitPart:ApplyImpulse(humanoidRootPart.CFrame.LookVector * power + humanoidRootPart.CFrame.UpVector * height)```

I’m not sure if it has to do with the math, even this line above doesn’t work somehow? When I was previously using BodyVelocities I never had any issues at all, but ApplyImpulse() seems to be working horribly for me and keeps breaking somehow.

2 Likes

figured it out, :ApplyImpulse() is very buggy on client and shouldn’t be used on client

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.