I've been looking into learning how to raycast for quite a long time now, I've looked through many discussion threads and tutorials, I never fully understood any of them so I decided to just take a crack at it myself.
local RayIgnoreList = {Gun.Model.Muzzle}
EventFired.OnServerEvent:Connect(function(plr,LookVector)
local Rey = Ray.new(Gun.Model.Muzzle.Position, LookVector)
local Part,position = workspace:FindPartOnRayWithWhitelist(Ray,{RayIgnoreList})
print(Part,position)
local part = Instance.new("Part", workspace)
part.Position = position
end)
I keep getting the error "Unable to cast value to Object" I found a few different threads asking the same question, but none of those told me what exactly the error meant. So, with no alternatives Im turning to scripting helpers.

5 comments
"Ray" is suppose to be "Rey" possibly
yea ik, I just called the variable that cause, why not.
it's you
I don't think you understand, line 6 has "Ray" as its first parameter but the ray you made is on line 4 called "Rey", replace the keyword "Ray" on line 6 param 1 with "Rey"
Oh, I see what you mean. Although, despite changing that, I still get the same error.