Laser Pointer raycast help

Hi guys, I am trying to make a laser pointer/laser sight, but even with the raycasts, the laser goes through walls because the End attachment does not update for some reason, or going to the position: 0,0,0 (it’s default position) when rotated at certain angles, and I cannot figure out as to why (I am using a beam for my laser), here’s my script:

local param = RaycastParams.new()
local att1 = script.Parent.Start
local att2 = script.Parent.End

while true do
	wait()
	local ray = game.Workspace:Raycast(script.Parent.Position, att2.CFrame.LookVector*15000, param)
	if ray then
		att2.Position = ray.Position - script.Parent.Position
	else
		att2.Position = att2.CFrame.LookVector*15000
	end
end

because you didnt fill in the params, you need to blacklist the walls from the raycast

2 Likes

oh

Do I need to list EVERY single part? I am new to raycasting

EDIT: Yeah ok I have to sorry for the dumb question

EDIT #2: Thanks! It worked

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.