How do I fix my knife not always throwing?

So my knife always doesn’t through because RayResult is nil

My Code:

			local Parameters = RaycastParams.new()

			Parameters.FilterType = Enum.RaycastFilterType.Blacklist
			Parameters.FilterDescendantsInstances = {Character, workspace.CurrentCamera, script.Parent.Handle}

			local Head = Character:WaitForChild("Head")

			local RayPosition = Mouse.Hit.p -- I think this is the issue
			local RayDirection = (Head.Position - workspace.CurrentCamera.CFrame.Position).Unit * 1000

			local RayResult = workspace:Raycast(RayPosition, RayDirection, Parameters)

I’ve tried look vecotr and current camera but it doesn’t work/now how i want it to.

You should first set the Origin of the Ray, not where the Mouse’s Position Hit:

Try this:

			local Parameters = RaycastParams.new()

			Parameters.FilterType = Enum.RaycastFilterType.Blacklist
			Parameters.FilterDescendantsInstances = {Character, workspace.CurrentCamera, script.Parent.Handle}

			local Head = Character:WaitForChild("Head")

			local RayPosition = script.Parent.Handle.Position 
			local RayDirection = (Head.Position - Mouse.Hit.Position).Unit * 1000

			local RayResult = workspace:Raycast(RayPosition, RayDirection, Parameters)

It works but it has a offset with the knife to the players head.

I tried using the head but that also didn’t work (at all).

Maybe just change the RayDirection’s Head Position to the script.Parent.Handle.Position instead?

That is still gltichy, like it goes off by 5 studs sometimes

			local Parameters = RaycastParams.new()

			Parameters.FilterType = Enum.RaycastFilterType.Blacklist
			Parameters.FilterDescendantsInstances = {Character, workspace.CurrentCamera, script.Parent.Handle}

			local Head = Character:WaitForChild("Head")

			local RayOrigin = script.Parent.Handle.Position 
			local RayDirection = (script.Parent.Handle.Position - Mouse.Hit.Position).Unit * 1000

			local RayResult = workspace:Raycast((RayOrigin + Vector3.new(0, -5, 0), RayDirection, Parameters)

Hm, maybe the Mouse’s Position isn’t exact or something? Try setting some offset I guess?

But the offest only happen sometimes.

Maybe try doing Magnitude instead of Unit? I’m just guessing at this point a