# This code makes an Apple heal you! using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /Verse.org/Simulation/Tags } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a tag so we can mark objects. # A tag is like a sticker we put on things. player_tag := class(tag) {} # We create a new class. # It lives inside a Creative Device. healing_apple_device := class(creative_device): # We connect this device to an item_spawner_device in the editor. # That device holds the Apple we want to give. @editable AppleDevice : item_spawner_device = item_spawner_device{} # This runs automatically when the game starts. OnBegin() : void = HealingAppleScript() # This function finds players and gives them an Apple. HealingAppleScript() : void = # We find all players on the island. # GetPlayspace gives us the current game session. # GetPlayers gives us everyone in it. Players := GetPlayspace().GetPlayers() # We check if there are any players. if (Players.Length > 0): # We pick the first player we find. # In a real game, you might loop through all of them. if (Player := Players[0]): # We tell the device to give an Apple to the player. # SpawnItemForPlayer gives the item directly to that player. # The Apple heals 5 health points when eaten. AppleDevice.SpawnItemForPlayer(Player) # We wait a little bit. # Then we try again later. # This makes it a loop! Sleep(5.0) HealingAppleScript()