// This is a simple Verse script to manage ammo pickups. using { /Fortnite.com/Devices } using { /Fortnite.com/Items } using { /Verse.org/Simulation } # Create a new "Ammo Manager" script ammo_manager := script() # This function is called when the script starts. # Think of it as "Pressing Start" on your island. on_start := func() { # We need to find the Item Granter device in our island. # Imagine looking through your inventory to find the "Item Granter" device. granter := GetDevice("AmmoBoxGranter") # Check if the device exists. If not, the script stops (or warns you). if (granter != nil) { # Set up the "Trigger" (Event) # We want to know when a player interacts with this granter. granter.InteractedWith.Subscribe(on_player_picks_up) # Print a message to the debug log (like the in-game chat) Print("Ammo Box is ready! Go grab it.") } } # This is the function that runs when the event happens. # "InteractedWith" is the event. This function is the reaction. on_player_picks_up := func(event : InteractedWithEvent) { # Get the player who touched the device player := event.Actor.GetOwner() # Check if the actor is actually a player (not a wall or a tree) if (player != nil) { # Create the Ammo Item. # We need to specify the type. Let's use "5.56mm" ammo. # In Verse, we use the Item class to define what item we want. ammo_item := CreateItem("5.56mmAmmo") # Give the item to the player. # This is like saying: "Take this ammo and put it in your inventory." player.GiveItem(ammo_item) # Optional: Print a message to the player Print(player.GetDisplayName() + " got some ammo!") # Optional: Disable the granter so it can't be used again (like a one-time chest) granter.Disable() } }