Keeper is flinging when it has ball

local function diveTowards(targetPos)
	if diving or diveCooldown or hasBall then return end

	diving = true
	diveCooldown = true
	hasBall = true

	humanoid.PlatformStand = true

	local direction = (targetPos - keeperRoot.Position)
	direction = clampVectorMagnitude(direction, divePowerLimit)

	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = direction / diveDuration
	bodyVelocity.MaxForce = Vector3.new(1e5, 1e5, 1e5)
	bodyVelocity.P = 10000
	bodyVelocity.Parent = keeperRoot

	task.delay(diveDuration, function()
		bodyVelocity:Destroy()
		keeperRoot.AssemblyLinearVelocity = Vector3.zero
		keeperRoot.AssemblyAngularVelocity = Vector3.zero

		if ball:FindFirstChild("KeeperBallWeld") then
			ball.KeeperBallWeld:Destroy()
		end

		ball.Anchored = false
		ball.CanCollide = false
		ball.AssemblyLinearVelocity = Vector3.zero
		ball.AssemblyAngularVelocity = Vector3.zero

		local weld = Instance.new("WeldConstraint")
		weld.Name = "KeeperBallWeld"
		weld.Part0 = keeperRoot
		weld.Part1 = ball
		weld.Parent = ball

		ball.Position = keeperRoot.Position + Vector3.new(0, -2, -1.5)

		task.delay(3, function()
			if weld and weld.Parent then
				weld:Destroy()
			end
			ball.CanCollide = true
			ball:ApplyImpulse(keeperRoot.CFrame.LookVector * 50 + Vector3.new(0, 20, 0))
			hasBall = false
		end)

		humanoid.PlatformStand = false
		diving = false

		task.delay(diveCooldownTime, function()
			diveCooldown = false
		end)
	end)
end

When the keeper touches the ball, it welds to keeper, but the keeper starts flinging everywhere.

Dont use BodyVelocity its outdated.
Use VectorForce instead.
You are turning player into a ragdoll by setting PlatformStand to true

LinearVelocity is the replacement for BodyVelocity.
VectorForce is the replacement for BodyForce/BodyThrust.

Also, using deprecated instances shouldn’t cause that drastic of a behavioral change. I suspect the real problem is the MaxForce used, which could definetly cause flinging when diving into physics objects:

Making this somewhat lower should fix the issue? Try 50000, 10000, 5000, and 1000 for each.

1 Like