Usually the way a buyout happens is one of 2 ways. Cash for your shares, or shares in the buying company for your shares, at an agreed upon ratio.
So you get value in both cases.
(Mergers are a slightly different animal, usually happening by the second instance.)
In any case, you own a piece of the company (thus a "share" is called that for a reason, it is a piece of the company.). So when someone buys the company, you get a "share" of the price proportionate to the amount of shares of stock you hold of the outstanding (O/S) count.
That is it in a nutshell.
Hope it clears up the question for you Shy. If not, ask more. I'll try to explain.
Don't take my word for it, Do your own research! Then you will know it's true!