ItemPurchase
Fires when an item is purchased in the Item Shop.
-- Refund 50% of all Iron purchases in the shop
Events.ItemPurchase(function(event)
-- Only refund the player if the resource used to purchase the item is Iron
if (event.costItem == ItemType.IRON) then
-- Round 50% of the price to the closest smaller integer
local refund = math.floor(event.price * 0.5);
InventoryService.giveItem(event.player, ItemType.IRON, refund, true)
end
end)Parameters
player: Player
itemType: ItemType
amount: number
costItem: ItemType
price: number
Last updated