IsInstanceValid returns false when it shouldn't

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

I have made this script to change the “body” parts of characters

[Tool]
public partial class MeshSelection : Node3D
{

    bool apply;
    [Export] bool Apply{
        get{
            return apply;
        }

        set{
           ApplyMeshes();
           apply = false;
        }
    }

    [Export] public PackedScene Joints;
    [Export] public PackedScene Surface;

    public override void _Ready()
    {
        ApplyMeshes();
    }

    public void ApplyMeshes()
    {
        if (!IsInstanceValid(Joints) || !IsInstanceValid(Surface))
        {
            GD.PrintErr("Not all meshes set");
            return;
        }

        Skeleton3D GeneralSkeleton = GetNode<Skeleton3D>("%GeneralSkeleton");
        foreach (Node child in GeneralSkeleton.GetChildren())
        {
            if (child is MeshInstance3D)
            {
                child.QueueFree();
            }
        }
        
        var joints = Joints.Instantiate<MeshInstance3D>();
        var surface = Surface.Instantiate<MeshInstance3D>();

        GeneralSkeleton.AddChild(joints);
        GeneralSkeleton.AddChild(surface);

        GeneralSkeleton.MoveChild(joints, 0);
        GeneralSkeleton.MoveChild(surface, 1);

    }
}

Basically I put in the MeshInstances in the “joints” and “surface” fields (Tho I don’t think it matters in which field I actually put them), then call the ApplyMeshes() function in order to replace the current meshes with the new ones.

This works in the editor, but when I put my character scene in a test scence and run it, I get the “Not all meshes set” error (I call the ApplyMeshes function at runtime in a Ready of another node), even though I did set them correctly in the character scene.

One weird thing is that if I make the character scene local to the test scene, the error seems to disappear, and even if I undo the make local, the error doesn’t return until I close and reopen the editor. So yeah idk what’s happening, but it probably has to do with the character scene being instanced.

Does anyone know what’s going on?

csharp

not sure why you use IsInstanceValid
if your Joints OR Surface is null or not valid
you print “Not all meshes set” for me is more like: “there’s no valid instance detected”