Knockback module teleporting the player

I’ve made a knockback module for my game but sometimes the player teleports to spawn / falls under the map. It doesn’t happen always and seems to be random. Any ideas?

Script:

local Knockback = {}

function Knockback:Knockback(SourcePosition, Target, Force)
	spawn(function()
		if Target:IsA("Model") == false then
			return
		end
		if Target.PrimaryPart == nil then
			return
		end

		if Force == nil then
			Force = {Back = 0, Up = 0}
		end

		local Parts = {}
		for i,v in pairs(Target:GetDescendants()) do
			if v:IsA("BasePart") then
				table.insert(Parts,v)
			end
		end

		for i,v in pairs(Parts) do
			v.Massless = true
		end

		local DirXZ = (SourcePosition - Target.PrimaryPart.Position).Unit * Vector3.new(1,0,1)

		local FinalForce = DirXZ * Force.Back + Vector3.new(0,Force.Up,0)

		local KnockBack = Instance.new("LinearVelocity")
		KnockBack.MaxForce = Vector3.new(3000, 3000, 3000)
		KnockBack.VectorVelocity = (-DirXZ * Force.Back) + Vector3.new(0,Force.Up,0)
		KnockBack.Parent = Target:FindFirstChild("HumanoidRootPart")
		game.Debris:AddItem(KnockBack, .1)

		wait(.05)

		for i,v in pairs(Parts) do
			v.Massless = false
		end
	end)	
end

return Knockback

You could always clamp the force’s ‘Y’ axis value to a minimum of 0.
math.min(ForceY, 0)

Turns out i just did the math wrong i think. I rewrote it and it works now