Skip to main content

πŸŽ’ Inventory

Very similar to the currency module, it's also programmed in a similar fashion.

Creating an inventory​

To create an inventory, do the following:

local Framework = require(path.to.framework).GetServer()
local Inventory = Framework.Inventory

Inventory.Create("RocketLaunchers")
Inventory.Finalise()

Modifying an Inventory​

To modify an inventory, you first need to get it.

-- again, assuming the player is defined.

local plrInv = Inventory.Get("RocketLaunchers", player)

BindToUpdate​

Fires a BindableEvent whenever the inventory is updated.

plrInv:BindToUpdate(function()
print("Updated")
end)

GetStored​

Returns the players data, only use when initialising the data.

local data = plrInv:GetStored()

Get​

Returns the players data, also.

local data = plrInv:Get()

Insert​

Insert is like lua's table.insert, except its for inventories.

plrInv:Insert("AdminLauncher")

Add​

This adds a dictionary into the inventory.

It takes two parameters:

  • Key
  • Data
plrInv:Add("AdminLauncher", {
Power = 100,
Cooldown = 10,
})

Edit​

Edits an existing key in the dictionary:

plrInv:Edit("AdminLauncher", {
Power = 500,
Cooldown = 5,
})

Remove​

Removes a value from the inventory.

plrInv:Remove("AdminLauncher")

HasItems​

Returns a boolean if the player has/hasn't got the item

local hasItem = plrInv:HasItem("AdminLauncher")

SearchItem​

Searches for an item, used when searching for an item in an array instead of a dictionary.

plrInv:SearchItem("AdminLauncher")

Wipe​

Wipes the inventory clean

plrInv:Wipe() -- :(