Raycasts not working

I am Trying to make a simple laser using raycasts.

I did some debugging and everything works fine except the “raycastResult” is nil, and there is a part in front of the laser for the raycast to hit.

Script:

function LaserBeam()
	local rayOrigin = script.Parent.Position
	local rayDirection = Vector3.new(0,0,-1000)

	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {script.Parent}
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
	
	print(tostring(raycastResult))

	if raycastResult then
		local hitPart = raycastResult.Instance
		local Pos = raycastResult.Position
		--if hitPart.Name == "Reflector" then
			local dist = (script.Parent.Position - Pos).Magnitude
			local Beam = Instance.new("Part")
			Beam.Anchored = true
			Beam. CanCollide = false
			print("Test")
			Beam.Size = Vector3.new(0.5, 0.5, dist)
			Beam.CFrame = CFrame.new(script.Parent.Position, Pos) * CFrame.new(0, 0, -dist/2)
			
			Beam.Parent = script.Parent.Parent
		--end
	end
end

script.Parent.ClickDetector.MouseClick:Connect(function()
	LaserBeam()
end)

You could try something like this to visually see your cast
You maybe casting in the wrong direction

local Part = Instance.new('Part')
local Mag = (workspace.Part1.Position - workspace.Part2.Position).Magnitude -- change this to origin and raydirection
Part.Size = Vector3.new(1,1,Mag)
Part.CFrame = CFrame.new(workspace.Part1.Position,workspace.Part2.Position)  -- change this to origin and raydirection
Part.CFrame = Part.CFrame + (Part.CFrame.LookVector * Part.Size.Z/2)
Part.Anchored = true
Part.CanCollide = false
Part.Parent = workspace

A RaycastResult is a table of results so it can’t be coerced into a string type value by passing it as an argument to the “tostring()” global, try indexing the some of its expected properties and print those instead.