Backpack

Show Deprecated

A container object that holds a Player's inventory. Any Tool in a player's Backpack will be displayed in their inventory at the bottom of their screen. Selecting Tools from the inventory will equip the Tool, moving it from the Backpack to the player's character.

The Backpack can also store Scripts and LocalScripts, which run when placed in a player's Backpack.

When a player's character spawns, the contents of the StarterPack and their StarterGear are copied into their Backpack. Once a character dies, the Backpack is removed and a new one will be created -- populating it with the contents of StarterPack and StarterGear.

Roblox provides an interface for a player to access their backpack and inventory by default at the bottom of the screen. If a developer wishes to disable the default Roblox backpack GUI and replace it with their own, they may do so using StarterGui:SetCoreGuiEnabled().

The Backpack can be accessed from both the client and the server.


1-- Accessing Backpack from a Server Script:
2game.Players.PlayerName.Backpack
3
4-- Accessing Backpack from a LocalScript:
5game.Players.LocalPlayer.Backpack"
6

Code Samples

Backpack Give Tool

1local Players = game:GetService("Players")
2
3local function giveTool(player, tool)
4 local backpack = player:FindFirstChildOfClass("Backpack")
5 if backpack then
6 tool.Parent = backpack
7 end
8end
9
10local function onPlayerAdded(player)
11 local tool = Instance.new("Tool")
12 giveTool(player, tool)
13end
14
15Players.PlayerAdded:Connect(onPlayerAdded)

Summary

Properties

Events

Methods

Properties

Events

Methods