# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/item-component-in-fortnite
# Local doc: epic-docs/documentation/en-us/fortnite/item-component-in-fortnite.md
# Section: Example
using { /Fortnite.com/Devices }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Itemization }
# This device will create an item for all players when they are added to Playspace. Once the item is created it will pick itself up to the Player's inventory.
item_giver_device := class(creative_device) :
OnBegin<override>()<suspends>:void=
AllPlayers := GetPlayspace().GetPlayers()
for(Player:AllPlayers):
# Adding the item_component to an entity turns it into an item.
NewEntity := entity{}
NewItemComponent:item_component = item_component{Entity := NewEntity}
NewEntity.AddComponents(array{NewItemComponent})
# Get an inventory from the Player.
# Pickup the item so it goes into the Player inventory.
if(TargetInventory := Player.GetInventoryRoot[]):
if(NewItemComponent.PickUp[TargetInventory]):
Print("Item successfully picked up.")
Verse Library
verse
01 Example
Spawns an item entity for each player at game start and automatically picks it up into their inventory.
extracted-snippets/documentation/en-us/fortnite/item-component-in-fortnite/01-example.verse