There are limited powers to raise money by borrowing. The Scotland Acts (2012 and 2016) allow for the Scottish government to borrow up to £3 billion (with an annual deficit capped at £450 million) An extension of £1.75billion can be agreed upon by both governments under terms of the fiscal framework (for counter-cyclical spending).
Scottish ministers can also borrow from the Secretary of State for Scotland to meet temporary shortfalls in cash or maintain the value of the Scottish Consolidated Fund (the block grant from Westminster to the Scottish Government)
Generally, the Scottish Government borrows through the UK government from the National Loans Fund. And so the UK government can function as a bank for the Scottish government. The UK government holds the Scottish reserve on account and provides loan facilities as a bank would provide to a private client.
See the Scottish Public Finance Manual/Borrowing, lending and investment and
the Fiscal Framework agreement