Sounds like it could be the clips for the sunshade have come apart and are fouling the tracks for the sunroof? If you remove the glass (6 torx) you should see what’s missing. There’s a link somewhere to YouTube for a BMW e46 sunroof repair how to which is a great help as it’s the same sunroof and has same issues
https://youtu.be/_XlTqpxUJgs