I’ve seen a lot of people ask this question, and if you don’t know I hope I help you.
Items Needed:
Barrier Prop
Button
Vending Machine
Take the barrier, design it anything you want.
In ‘Featured’ Click Yes for Collision Enabled.
Now, go to Availability, and on ‘Visible when game starts’ click No.

After that, switch to your Button and in ‘Featured’, make the button message "Buy Barrier ( - Energy) (In that space put how much energy you want.
Make sure your button settings look like mine.
Now switch to your vending machine.
In Featured, ‘Purchase Action click Grant Item.
Under Required Item, Put Energy.
In Required Item Amount, put your desire.
In When Item Purchased, Transmit On’ Type Barrier On.
In Visible-In-Game, put no.
Now connect button to the vending machine. [Button Pressed- Attempt to Purchase]
And wire the vending machine to the barrier. [Item Purchased- Show Prop]
It should look something like this at the end.
After that, Voila, you’re done!