Issues with raycasting

I’m receiving the error “Unable to cast value to Objects” on line 7. Any help would be greatly appreciated!

local cast_part = script.Parent

local ray1 = Ray.new(cast_part.Position, Vector3.new(0,50,0))

while wait(2) do
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray1,(cast_part))
	if hit then
		print("Ray was hit!")
	else
		print("Ray was not hit.")
	end
end

Try this:

local cast_part = script.Parent

local ray1 = Ray.new(cast_part.Position, Vector3.new(0,50,0))

while wait(2) do
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray1,{cast_part})
	if hit then
		print("Ray was hit!")
	else
		print("Ray was not hit.")
	end
end
1 Like

Thank you sir, my script works now