Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What mistake have I made with raycasting?

Asked by 3 years ago

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.

0
"Ray" is suppose to be "Rey" possibly greatneil80 2647 — 3y
0
yea ik, I just called the variable that cause, why not. generalYURASKO 144 — 3y
0
it's you DiamondComplex 285 — 3y
0
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" greatneil80 2647 — 3y
0
Oh, I see what you mean. Although, despite changing that, I still get the same error. generalYURASKO 144 — 3y

Answer this question