# Import the basic Verse framework using /Fortnite.com/Devices using /Verse.org/Simulation using /Verse.org/Random # This script attaches to an Item Granter device slap_spawner := class(creative_device): # This is the "Inventory Slot" for our script. # It holds a reference to the Item Granter device placed on your island. # Wire this up in the UEFN editor by selecting the device in the Details panel. @editable MyGranter : item_granter_device = item_granter_device{} # This is a second Item Granter used as the re-grant source. # Configure it in the UEFN editor to hold a Slap Berry, Reset on Grant = true. # When GrantItem() is called on it, it fires its configured item at the player. @editable MyRespawnGranter : item_granter_device = item_granter_device{} # OnBegin runs once when the game starts. # We use it to subscribe to the granter's ItemGrantedEvent so we # react every time the granter gives an item to a player. OnBegin() : void = # Subscribe: whenever MyGranter grants an item, call our respawn function. MyGranter.ItemGrantedEvent.Subscribe(HandleSlapGranted) # This function fires each time MyGranter grants its item to a player. # 'GrantingPlayer' is whoever received the item. HandleSlapGranted(GrantingPlayer : player) : void = # Re-grant a new Slap item to the same player immediately. # MyRespawnGranter should be configured in the editor with # the Slap Berry (or Slap Juice) you want to duplicate. MyRespawnGranter.GrantItem(GrantingPlayer) # Optional: Print a message to the debug screen for testing. Print("Slap granted! Energy: MAX")