But you (we) have left as per the referendum. And Spain won't allow it.
We haven't left yet. We haven't even triggered the negotiating process yet.
Anyway, I don't think it would be possible for Scotland to stay in the EU and the rest of the UK to leave, at least not without erecting border controls.
What will happen is we leave the EU, Scotland has another referendum that the UK Leavers win and then they apply for membership of the EU. They will get in with some negotiation.