Raycasting but when click nothing detects

I’m trying to raycast to character and attach part to character, but when I click to place, it just doesn’t detect any part…
How can I fix this?

game:GetService("UserInputService").InputBegan:Connect(function(input, inChat)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and tool.Parent:IsA("Model") then
		if placing == false then --turn place mode on, display where it will place using raycast
			print("place")
			placing = true
			while placing == true do
				local camPos = workspace.CurrentCamera.CFrame.Position
				local mouse = game:GetService("Players").LocalPlayer:GetMouse()
				local rayResult = workspace:Raycast(camPos, CFrame.new(camPos, mouse.Hit.p).LookVector * ((camPos - mouse.Hit.p).magnitude + 0.01), ray)
				if rayResult then --this one works
					hologram.CFrame = CFrame.new(rayResult.Position, rayResult.Position + rayResult.Normal) * CFrame.Angles(math.rad(-90), 0, 0)
					hologram.Parent = workspace
				else
					hologram.Parent = nil
				end
				game:GetService("RunService").Heartbeat:Wait()
			end
		else --place
            --these lines are exactly same
			local camPos = workspace.CurrentCamera.CFrame.Position
			local mouse = game:GetService("Players").LocalPlayer:GetMouse()
			local rayResult = workspace:Raycast(camPos, CFrame.new(camPos, mouse.Hit.p).LookVector * ((camPos - mouse.Hit.p).magnitude + 0.01), ray)
			print(rayResult) --nil
			if rayResult then
				print("done") --yes this line never prints
				placing = false
			end
		end
	end
end)

Maybe replace ((camPos - mouse.Hit.p).magnitude + 0.01 with 999

Whats the “ray” in place for the raycastparams?

local rayResult = workspace:Raycast(camPos, (mouse.Hit.Position - camPos).Unit * 500, ray)

Raycast()'s second argument should be a directional unit vector multiplied by some scalar (the vector’s magnitude).

Is the part ur trying to “hit” have canquery off? If so, enable it.