The answer is: it's actually not dependent upon your residency, but on your domicile.
If you were born in the UK or your father was born in the UK, you are classed as ordinarily domiciled in the UK, and therefore your worldwide assets would be liable for UK inheritance tax.
If you haven't lived in the UK for a long time, and you have no intention of returning, and you've got absolutely no ties to the UK - no bank accounts, no investments, no property, then you should contact HMRC and sever your domicile and make your domicile whichever country you're living in, and therefore you won't be liable for UK inheritance tax.
If you are a non-resident, but you also have assets in the UK like property for example, then those assets will be liable for UK inheritance tax even if you're nondomicile and you're living abroad. Any UK assets are liable for UK inheritance tax.
That's how it works for non-residents. If somebody comes to the UK and they're not domiciled, then what happens? They have to be living here 15 out of the last 20 years and then they're deemed domicile, in which case their worldwide assets are now liable for UK inheritance tax.
Domicile is quite a complex question. If in doubt, make sure you get expert advice on that scenario