I was testing out ray cast, and I made this script:
1 | while wait( 1 ) do |
2 | local ray = Ray.new(script.Parent.Position, Vector 3. new( 0 , 500 , 0 )) |
3 | local hit = game.Workspace:FindPartOnRayWithIgnoreList(ray, script.Parent) --HERE |
4 | print (hit) |
5 | 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 :-)
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
1 | local hit = game.Workspace:FindPartOnRayWithIgnoreList(ray, { script.Parent } ) |