PVInstance can't cast to Instance

This is an issue I’ve been having.
A PVInstance like a BasePart will not be capable of casting to an Instance type.
Is this intended behaviour?
I sure would understand the other way around wouldn’t work, but from PVInstance to Instance?
What makes it incapable of casting?

RaycastParams.FilterDescendantsInstances needs {Instance} and doesn’t accept {PVInstance} and {PVInstance} lacks the capability to cast to {Instance}


afbeelding

Expected behavior

I would expect a PVInstance to cast to Instance just fine, though I once again have my doubts about the intended behaviour.

Edit: I have my doubts about the bug reporting category, if this falls under Studio or Engine bugs.

3 Likes

This is just an acknowledgment announcement!

We’ve filed a ticket into our internal database for this issue, and we will update you when we have further information!

Thanks for the report!

This is expected behaviour.

The reason we must warn here is that Luau cannot know if you are going to mutate RaycastParameters.FilterDescendantsInstances or not. Since its type is {Instance}, it would be permissible to insert a Folder into the array, and then your {BasePart} would contain things that are not BaseParts at all.

We have a feature in mind to help out in this situation, but it will be a little while before it is ready. In the meantime, you can work around this by casting Settings.Parts :: any.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.