Backpack
Inherits from Instance
A container class that holds a players' inventory. If a Tool is placed in the player's Backpack, it will be displayed in their inventory.
Not CreatableSummary
Selecting a Tool from the inventory will equip the Tool, which will move it from the Backpack to the Player.
The Backpack is also able to store Scripts and LocalScripts that can run when placed inside.
When the player spawns, the contents of the Backpack are copied into the Player. When they die, the contents will be removed and a new one will be created.
In Polytoria you can access the backpack and inventory with a script. If you wish to disable the hotbar you can also use the CoreUI.HotbarEnabled property.
The backpack can be accessed both from the client and the server.
local Players = game["Players"]
-- Accessing Backpack from the Server
local backpack = Players["PlayerName"].Backpack
-- Accessing Backpack from the Client
local backpack = Players.LocalPlayer.Backpack
Code Samples
Backpack Give Tool
This sample includes a simple function on how a Tool can be given to a player by parenting it to their Backpack.
local Players = game["Players"]
local function onPlayerAdded(player)
local tool = Instance.New("Tool")
local backpack = player["Backpack"]
tool.Parent = backpack
end
Players.PlayerAdded:Connect(onPlayerAdded)