# This script makes a potion shop work.
# We need to talk to the button and the player.
# A "Device" is any object in our game world.
# We use "Event" to wait for something to happen.
Event OnPlayerInteracts(player: Player, button: TextButton):
# Check if the player is the one pressing the button.
# We use "if" to ask a question.
if button.IsPressed(player):
# Check the player's score.
# Score is like a variable that counts points.
# We treat score as "coins" for this shop.
coins := player.GetScore()
# Does the player have 10 coins?
if coins >= 10:
# Take 10 coins away.
# This is like paying for the item.
player.SetScore(coins - 10)
# Give the player a Health Potion.
# We use "Grant" to add an item to their inventory.
# "Health_Potion" is the name of the item.
player.Grant(Health_Potion)
# Tell the player "Thanks!"
# We use "ShowMessage" to talk to them.
Verse Library
verse
01 Fragment
Sells health potions to players for a currency fee when they press an interact button.
verse-library/using-consumables-in-fortnite-creative/01-fragment.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.