It's also possible that Scotland's independence happens before or simultaneously with the UK's exit, in which case Scotland could remain a EU member by continuity. This would also be a good lifeline for the rest of the UK once they recover from their spell of madness - form a union with Scotland to sneak back in.