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 :-)
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})