Invalid argument #1 (CFrame expected, got Vector3)

I am using this script below to create a laser using a Beam, and it keeps erroring and I don’t know why. I am pretty new to raycasts so I’m not sure what I’m doing wrong.

local laserThickness = .1
local castLength = 500

local beam = script.Parent.Beam
local startatt = script.Parent.StartAttachment
local endatt = script.Parent.EndAttachment

local params =
params.FilterDescendantsInstances = {}

	local laserLook = script.Parent.CFrame.LookVector
	local laserOrigin = startatt.Position

	local castResult = workspace:Raycast(laserOrigin,laserLook*castLength,params) or {Position = laserOrigin+laserLook*castLength,Distance = castLength}
	endatt.CFrame =, .5, castResult.Position) * CFrame.Angles(0, math.pi/2,0))

just do instead of laserOrigin

And where would I insert that in the script?

at local castResult

It just says Unable to cast CoordinateFrame to Vector3 now as an error.

try changing local laserOrigin = startatt.Position to local laserOrigin = startatt.CFrame

You placed an end bracket in the wrong place:

endatt.CFrame =, .5, castResult.Position)) * CFrame.Angles(0, math.pi/2,0)