Spain wouldn't block Scotland's entry to the EU, it comes down to fishing rights, amongst other things:
"However there is another reason closer to the heart of the Spanish Prime Minister Mariano Rajoy that Spain won’t block Scottish accession to the EU. Interestingly, during the last independence referendum Rajoy was asked three times in an interview with El Pais newspaper whether he would veto Scotland, and three times he refused to reply. He refused to reply because he didn’t want to encourage Scottish independence by telling the truth.
Mariano Rajoy comes from Galicia, and represents the city of A Coruña in the Spanish parliament, the Cortes. The mainstay of the local economy is the fishing industry, and big fishing interests are the main funders of Rajoy’s own local party. The Galician fishing fleet depends on its access to Scottish waters in order to feed Spain’s enormous appetite for seafood, and any attempt by Spain to veto Scottish membership of the EU would threaten that access. Rajoy would then find that his local party’s bank balance was as empty as the fish counter in a Spanish supermarket. He’s not going to let that happen."
https://weegingerdug.wordpress.com/2016/06/25/an-argument-as...
See also:
http://wingsoverscotland.com/what-mariano-rajoy-didnt-say/