💰ShopService

Service for adding and removing items from the shop.

Example usage:

Events.MatchStart(function(event)
    -- Adds 1 Solar Panel to the shop that can be purchased for 3 Diamonds
    ShopService.addItem(ItemType.SOLAR_PANEL, 1, ItemType.DIAMOND, 3)
    -- Adds 1 Tennis Racket to the shop that can be purchased for 15 Iron
    ShopService.addItem(ItemType.TENNIS_RACKET, 1, ItemType.IRON, 15)
end)

Functions

getAllShopkeeperIds(): string[]

Returns all current shopkeepers (by ID) in the game.

spawnShopkeeper(shopType: "items" | "upgrade", position: Vector3): string

Creates an item shopkeeper or upgrade shopkeeper at the given position. Returns the ID (string) of the created shop.

despawnShopkeeper(shopId: string)

Deletes the shopkeeper with the given ID (string).

addItem(item: ItemType, amount: number, costItem: ItemType, price: number)

Adds an item to the shop for all players.

  • amount - The amount of the item received when purchased

  • costItem - The type of item needed to purchase the specified item

  • price - The amount of the cost item needed to purchase the specified item

removeItem(item: ItemType)

Removes the item from the shop for all players.

Last updated