Loot Tables

The Loot Tables package allows you to quickly and easily add weighted probability loot tables to your game.

It’s intentionally left generic, letting you implement it any way you want. Some examples:

  1. Award the player with items from a loot table after they complete a minigame
  2. Throw physics enabled items out of an enemy when they die
  3. Add an item directly the player’s inventory when they interact with something
  4. Use a loot table for possible fish in a fishing hole

Message me on discord if you need any help implementing your specific need.


Search for “Loot Table” in the packager.

Creating a Loot Table

  1. Locate the Loot Table template in the template library and duplicate it
  2. Name your new Loot Table something meaningful like “Loot Table - Boss Drops”
  3. Right click your new Loot Table and click Edit.
  4. In the world tree, click on your Loot Table and give it a name.
  5. Right click the Loot Table, hover over Add → Script → lootTableItemScript

This creates a single entry in your loot table. With this you would specify a single item, and it’s weight.
For every item you want to in this loot table, you would repeat step 5.

Drag this template into the word and simulate the parent - you will see the probabilities printed.


Loot Table uses weighted probabilities to determine drop rates. For example, if you had a loot table of:

Item A: 3
Item B: 1

Then the probability of dropping Item A is 75%, and the probability of dropping Item B is 25%.

Utilizing a Loot Table

To utilize a loot table, drag the template you created onto the item you want to utilize it.


Right click on your chest and add a new script - let’s call it “LootDropperScript”, and place something like this inside:

local LootDropperScript = {}

-- Script properties are defined here
LootDropperScript.Properties = {
	-- Example property
	--{name = "health", type = "number", tooltip = "Current health", default = 100},

--This function is called on the server when this entity is created
function LootDropperScript:Init()
	self.lootTable = self:GetEntity().lootTableScript

function LootDropperScript:OnInteract()
	local itemToDrop = self.lootTable:FindItemByChance()
	if itemToDrop then 
		GetWorld():Spawn(itemToDrop, self:GetEntity():GetPosition() + Vector.New(0, 0, 100), self:GetEntity():GetRotation())

return LootDropperScript

Now, if the player interacts with the chest, it will spawn the items just above it.


July 06 2022

  • There’s a new property “lootTableName” on a lootTableItemScript. If you have multiple loot tables on a single entity, set this to the loot table name you want the item associated with. Otherwise leave it blank.
  • If an item template in a loot table defines a weight property in a script, Loot Tables will now use that value instead of the one specified in the lootTableItemScript
  • There’s a new lootTableManagerScript template that has the FindLooTable(name) method available on it. Use this if you have multiple loot tables on a single entity and want to easily get references to different loot tables.
1 Like