Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

(ANSWERED)I tried to use ray cast, and it gave me an error, why?

I was testing out ray cast, and I made this script:

while wait(1) do
local ray = Ray.new(script.Parent.Position, Vector3.new(0,500,0))
local hit = game.Workspace:FindPartOnRayWithIgnoreList(ray, script.Parent) --HERE
print(hit)
end

and it gave me the error: Unable to cast value to Objects Someone please tell me how I can fix it. Any form of help is appreciated :-)

1 answer

✓ Accepted answer

The second argument to :FindPartOnRayWithIgnoreList needs to be an array of objects. If you only want to have script.Parent, then you could rewrite it as

local hit = game.Workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.