When I finish lerping part is stuck inside wall

So, I’m using a bezier lerp function, and at the end half of the basketball is stuck in the part, Im not sure how to fix this i had a few ideas but they didnt work.

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,finish) --Mouse.hit.p
	Tool.Parent = workspace.RandmToolsInTheMap
	local magnitude = (Tool.Handle.Position-finish).Magnitude
	local origin = Tool.Handle.Position
	local breakVal = false;
	Tool.Handle.Touched:Connect(function(part)
		if part.Parent:FindFirstChild("Humanoid") then
			breakVal = true
			Tool.Handle.Anchored = false
		end
	end)
	finish += Vector3.new(magnitude/30*math.random(1,5)/10,magnitude/30*math.random(1,5)/10,0) --+Vector3.new(Tool.Handle.Position.Unit/2);
	local middle = (finish-Start) + Vector3.new(0,12.5,0)
	Tool.Handle.Anchored = true
	for i = 1,100 do
		RunService.Heartbeat:wait()
		local te = i/100
		if breakVal or i == 98 then
			break
		end
		Tool.Handle.Position = quadBezier(origin,middle,finish,te)
	end
	Tool.Handle.Anchored = false
	local m = -quadBezier(origin,middle,finish,100).Unit*80
	m+=Vector3.new(0,m.Y*-2,0)
	Tool.Handle.AssemblyLinearVelocity = m
end)

I just need to alter the Finish Position so half of it isnt stuck in the wall, just not sure how, something to do with the size of the ball and dividing it but still nothing.

1 Like

You have it set to where the for loop breaks when i == 98.

Perhaps that’s causing it to pause like that before reaching the hoop? What happens if you take that if statement out

  1. Thats not the problem
  2. Even if I remove the Break it will still pause like that
    heres a quick diagram of what i need

What would happen if you set the finish vector to be slightly more forward?

It looks to me like you’re using that one bezier module for bezier curves given the QuadBezier function I saw in there. I’ve had my fair share of troubles with it if that’s the case

To set the finish vector forward, I would do something in the code such as:

finish.CFrame = finish.CFrame * CFrame.new(0, 0, -3) -- or +3 depending on direction

But how would I know exactly what to add or subtract it by? Thats what im struggling with

finish += quadBezier(origin,middle,finish,100).Unit*2.5

Worked.

1 Like