FindPartOnRay not detecting part consistently

I’m making a gun for the player and when they’re shooting it fires a remote event 20 times a second (20 shots per second) and in that I’ve got this script:

game.ReplicatedStorage.UpdateBeamEvent.OnServerEvent:Connect(function(Player,FromP,ToP,length)
	local ray = Ray.new(FromP, (ToP-FromP))
	
	local att0 = game.Workspace.Terrain:FindFirstChild(Player.Name.."Att0")
	local att1 = game.Workspace.Terrain:FindFirstChild(Player.Name.."Att1")
	
	att0.Position = FromP
	att1.Position = ToP
	
	local hitRay = Ray.new(att0.Position,(att1.Position-att0.Position))
	local Part, Position = game.Workspace:FindPartOnRay(hitRay,Player.Character,false,true)
	
	if Part then
		print("hit!")
	else
		print("miss!")
	end
end)

Even when I’m clearly clicking straight at the ground it will sometimes print miss over and over, but sometimes it won’t. I don’t know why its so inconsistent. The two attachment parts are for the beam and I basically just want to check if the player is hitting anything within that range with a ray but it’s just SO inconsistent and I can’t figure out why.

If I can just get the ray to work and check based on the length parameter then I would be very happy.

Maybe instead of using FindPartOnRay use FindPartOnRayWithIgnoreList. Then set the the ignore list parameter to the characters descendants.