商品摊位

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

商品摊位 开发者模块 让您可以在体验中直接出售 角色资产通行证开发者产品。玩家可以浏览物品,在自己的角色上预览资产,购买物品,并立即使用或装备这些物品——这一切都无需离开您的体验。这可以帮助您 变现 您的体验,通过出售其他创作者的物品获得 40% 的加盟费。

模块使用

安装

要在体验中使用 商品摊位 模块:

  1. 从 Studio 的 窗口 菜单或 首页 选项卡工具栏中,打开 工具箱 并选择 创作者商店 选项卡。

  2. 确保选定 模型 排序,然后点击 查看所有 按钮以查看 类别

  3. 找到并点击 套餐 瓦片。

  4. 找到 商品摊位 模块并点击它,或者将其拖放到 3D 视图中。

  5. 资源管理器 窗口中,将整个 商品摊位 模型移动到 ReplicatedStorage。在运行体验时,模块将开始运行。

配置

该模块已预先配置以适用于大多数用例,但可以通过 配置 函数轻松自定义。例如,要创建一个更清新的主题并禁用目录视图左上方的默认 过滤器 按钮:

  1. StarterPlayerScripts 中,创建一个新的 LocalScript 并重命名为 ConfigureMerchBooth

  2. 将以下代码粘贴到新脚本中。

    LocalScript - ConfigureMerchBooth

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    MerchBooth.configure({
    backgroundColor = Color3.fromRGB(220, 210, 200),
    textSize = 17,
    textFont = Enum.Font.Fondamento,
    textColor = Color3.fromRGB(20, 20, 20),
    useFilters = false
    })

添加物品

没有商品摊位的商品摊位怎么行呢?以下部分概述了如何向您的商品摊位添加 角色资产通行证开发者产品

角色资产

衣物和配饰 等物品必须通过其在 头像商店 的详细信息页面上找到的 资产 ID 添加。

  1. ServerScriptService 中创建一个 Script 并粘贴以下代码。

    Script - Add Avatar Assets

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId)
    end)
    if not success then
    warn(errorMessage)
    end
    end
  2. 从其 头像商店 网站 URL 中复制物品的资产 ID。例如,Roblox 棒球帽 的 ID 是 607702162

  3. 将每个复制的 ID 粘贴到 items 表中的以逗号分隔的列表中。默认情况下,物品在目录视图中按字母顺序出现,但您可以使用 setCatalogSort 自定义排序。

    Script - Add Avatar Assets

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    607702162, -- Roblox 棒球帽
    4819740796, -- Robox
    1374269, -- 小猫耳
    11884330, -- 书呆子眼镜
    10476359, -- 纸帽
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId)
    end)
    if not success then
    warn(errorMessage)
    end
    end

通行证

添加 通行证 需要通行证 ID,可以在 创作者仪表板 中找到。

  1. ServerScriptService 中创建一个 Script 并粘贴以下代码。

    Script - Add Passes

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId)
    end)
    if not success then
    warn(errorMessage)
    end
    end
  2. 导航到 创作者仪表板 并选择体验。

  3. 在左侧栏中,点击 变现 下的 通行证

  4. 将鼠标悬停在通行证缩略图上,点击 按钮,并从上下文菜单中选择 复制资产 ID

  5. 将每个复制的 ID 粘贴到 items 表中的以逗号分隔的列表中 并且addItemAsync 的第二个参数包含 Enum.InfoType.GamePass 以指示这些物品是通行证。默认情况下,物品将在目录视图中按字母顺序出现,但可以使用 setCatalogSort 自定义排序。

    Script - Add Passes

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    4343758, -- ColdFyre 盔甲
    28521575, -- 冒险者防护盾
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId, Enum.InfoType.GamePass)
    end)
    if not success then
    warn(errorMessage)
    end
    end

开发者产品

添加 开发者产品 需要产品 ID,可以在 创作者仪表板 中找到。

  1. ServerScriptService 中创建一个 Script 并粘贴以下代码。

    Script - Add Developer Products

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId)
    end)
    if not success then
    warn(errorMessage)
    end
    end
  2. 导航到 创作者仪表板 并选择体验。

  3. 在左侧栏中,点击 变现 下的 开发者产品

  4. 将鼠标悬停在产品的缩略图上,点击 按钮,并从上下文菜单中选择 复制资产 ID

  5. 将每个复制的 ID 粘贴到 items 表中的以逗号分隔的列表中 并且addItemAsync 的第二个参数包含 Enum.InfoType.Product 以指示这些物品是开发者产品。默认情况下,物品将在目录视图中按字母顺序出现,但您可以使用 setCatalogSort 自定义排序。

    Script - Add Developer Products

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    1236602053, -- 法力回复
    1257880672, -- 治疗药水
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId, Enum.InfoType.Product)
    end)
    if not success then
    warn(errorMessage)
    end
    end

自定义目录按钮

默认情况下,右侧的 目录按钮 使玩家可以随时打开摊位。

在某些情况下,可能需要 移除 此按钮并连接自己的按钮:

  1. 创建一个新按钮,方法请参考 按钮

  2. 创建一个 LocalScript 作为按钮对象的子对象。

  3. 将以下代码粘贴到新脚本中。

    LocalScript - Custom Catalog Button

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    -- 移除默认目录按钮
    MerchBooth.toggleCatalogButton(false)
    -- 连接自定义按钮
    script.Parent.Activated:Connect(function()
    MerchBooth.openMerchBooth()
    end)

可购买区域

自动显示商品摊位的一个有效方式是在玩家进入区域时显示它。

要创建可购买区域:

  1. 创建一个 Anchored 块以涵盖检测区域。确保该块足够高,以便与角色模型的 PrimaryPart 碰撞(默认情况下是 HumanoidRootPart)。

    检测玩家接近商店柜台前面的块
  2. 在块属性的 标签 部分,将标签 ShopRegion 应用到块上,以便 CollectionService 进行检测。

  3. 将部件的 Transparency 设置为最大值,以在体验中隐藏它。此外,禁用其 CanCollideCanQuery 属性,以便对象不会物理碰撞,并且射线检测不会检测到它。

  4. StarterPlayerScripts 下插入一个新的 LocalScript

  5. 在新脚本中,粘贴以下代码,该代码使用 TouchedTouchEnded 事件检测角色何时进入/离开区域,同时调用 openMerchBoothcloseMerchBooth 打开/关闭摊位 GUI。

    LocalScript

    local Players = game:GetService("Players")
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local CollectionService = game:GetService("CollectionService")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    -- 移除默认目录按钮
    MerchBooth.toggleCatalogButton(false)
    local function setupRegion(region: BasePart)
    region.Touched:Connect(function(otherPart)
    local character = Players.LocalPlayer.Character
    if character and otherPart == character.PrimaryPart then
    MerchBooth.openMerchBooth()
    end
    end)
    region.TouchEnded:Connect(function(otherPart)
    local character = Players.LocalPlayer.Character
    if character and otherPart == character.PrimaryPart then
    MerchBooth.closeMerchBooth()
    end
    end)
    end
    -- 遍历现有标记的商店区域
    for _, region in CollectionService:GetTagged("ShopRegion") do
    setupRegion(region)
    end
    -- 检测何时非流式商店区域流入
    CollectionService:GetInstanceAddedSignal("ShopRegion"):Connect(setupRegion)

接近提示

作为 2D 目录视图的替代方案,您可以在体验对象上添加 接近提示。这鼓励玩家在 3D 环境中发现物品,预览它们在自己角色上的效果,购买它们并立即装备它们。有关详细信息,请参见 addProximityButton

更改装备效果

默认情况下,商品摊位在玩家从中装备物品时会显示一个通用的闪光效果。要更改该效果,请在 configure 调用中将 particleEmitterTemplate 设置为您自己的 ParticleEmitter 实例。

LocalScript - ConfigureMerchBooth

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local myParticleEmitter = Instance.new("ParticleEmitter")
myParticleEmitter.SpreadAngle = Vector2.new(22, 22)
myParticleEmitter.Lifetime = NumberRange.new(0.5, 1.5)
myParticleEmitter.Shape = Enum.ParticleEmitterShape.Sphere
myParticleEmitter.Transparency = NumberSequence.new(0, 1)
myParticleEmitter.RotSpeed = NumberRange.new(200, 200)
MerchBooth.configure({
particleEmitterTemplate = myParticleEmitter
})

GUI 可见性

默认情况下,当商品摊位的 UI 显示时,隐藏所有 ScreenGuisCoreGuis,包括聊天、排行榜及 Roblox 包含的其他内容。如果您希望禁用此行为,请在 configure 调用中将 hideOtherUis 设置为 false

LocalScript - ConfigureMerchBooth

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.configure({
hideOtherUis = false
})

字符移动

在角色位于商品摊位时阻止角色移动可能是一个好主意。这可以通过在 configure 调用中将 disableCharacterMovement 设置为 true 来完成。

LocalScript - ConfigureMerchBooth

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.configure({
disableCharacterMovement = true
})

API 参考

类型

物品

商品摊位中的物品由包含以下键值对的字典表示。物品可以通过 getItems 函数或 itemAdded 事件收集。

类型描述
assetIdnumber物品的目录 ID,作为参数传递给 addItemAsync
titlestring物品在目录中显示的标题。
pricenumber物品的价格,以罗布克斯为单位。
descriptionstring物品在目录中显示的描述。
assetTypestring表示物品的配件类型的字符串。
isOwnedbool当前玩家是否拥有该物品。
creatorNamestring目录中显示的物品创建者。
creatorTypeEnum.CreatorType物品的创建者类型。

枚举

MerchBooth.Controls

setControlKeyCodes 一起使用,以自定义与商品摊位交互的键和游戏手柄按钮。

名称概述
ProximityPrompts当配置了 接近提示 时,打开物品视图的按键和/或游戏手柄按钮。
OpenMerchBooth打开商品摊位的按键和/或游戏手柄按钮。
CloseMerchBooth关闭商品摊位的按键和/或游戏手柄按钮。
Filter使用目录视图左上角的默认 过滤器 下拉框的按键和/或游戏手柄按钮。
ViewItem打开特定商品摊位物品视图的按键和/或游戏手柄按钮。
LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setControlKeyCodes(MerchBooth.Controls.ProximityPrompts, {
keyboard = Enum.KeyCode.Q,
gamepad = Enum.KeyCode.ButtonL1
})

函数

configure

configure(config: table)

通过 config 表中的以下键/值覆盖默认的客户端配置选项。该函数只能从 LocalScript 中调用。

描述默认值
backgroundColor窗口的主背景颜色 (Color3)。[0, 0, 0]
cornerRadius主窗口的角半径 (UDim)。(0, 16)
cornerRadiusSmall窗口内部元素的角半径 (UDim)。(0, 8)
textFont主文本的字体,例如价格、描述及其他一般信息 (Enum.Font)。Gotham
textSize主文本的大小。14
textColor主要文本的颜色 (Color3)。[255, 255, 255]
secondaryTextColor用于主要文本某些变化的颜色 (Color3)。[153, 153, 158]
headerFont窗口标题所用的标题文本字体 (Enum.Font)。GothamMedium
headerTextSize窗口标题所用的标题文本大小。18
titleFont物品详细信息页面上物品名称所用的标题文本字体 (Enum.Font)。GothamBold
titleTextSize物品详细信息页面上物品名称所用的标题文本大小。28
buttonColor可点击状态下较大按钮的背景颜色,例如物品视图中的主要购买按钮 (Color3)。[255, 255, 255]
buttonTextColor可点击状态下较大按钮的文本颜色,例如物品视图中的主要购买按钮 (Color3)。[0, 0, 0]
secondaryButtonColor较小按钮的背景颜色,例如目录视图中的价格按钮或 试穿 按钮 (Color3)。[34, 34, 34]
secondaryButtonTextColor较小按钮的文本颜色,例如目录视图中的价格按钮或 试穿 按钮 (Color3)。[255, 255, 255]
inactiveButtonColor不可点击状态下所有按钮的背景颜色 (Color3)。[153, 153, 158]
inactiveButtonTextColor不可点击状态下所有按钮的文本颜色 (Color3)。[255, 255, 255]
particleEmitterTemplate在装备时出现并播放的自定义 ParticleEmitter 实例(可选)。
LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.configure({
backgroundColor = Color3.fromRGB(255, 255, 255),
textSize = 16,
textFont = Enum.Font.Roboto,
textColor = Color3.fromRGB(20, 20, 20),
hideOtherUis = false,
})

addItemAsync

addItemAsync(assetId: number, productType: Enum.InfoType, hideFromCatalog: boolean)

异步地将物品添加到商品摊位,以使其可以在体验中购买。 assetId 是物品的资产 ID,productType 是物品的 Enum.InfoType 枚举,hideFromCatalog 可用于在目录视图中隐藏该物品。

有关详细信息,请参见 添加物品,因为用于 资产游戏通行证开发者产品 的用法略有不同。

Script - Add Avatar Assets

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local items = {
607702162, -- Roblox 棒球帽
4819740796, -- Robox
1374269, -- 小猫耳
11884330, -- 书呆子眼镜
10476359, -- 纸帽
}
for _, assetId in items do
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(assetId)
end)
if not success then
warn(errorMessage)
end
end
Script - Add Passes

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local items = {
4343758, -- ColdFyre 盔甲
28521575, -- 冒险者防护盾
}
for _, assetId in items do
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(assetId, Enum.InfoType.GamePass)
end)
if not success then
warn(errorMessage)
end
end
Script - Add Developer Products

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local items = {
1236602053, -- 法力回复
1257880672, -- 治疗药水
}
for _, assetId in items do
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(assetId, Enum.InfoType.Product)
end)
if not success then
warn(errorMessage)
end
end

getItems

getItems(): table

返回表示所有当前注册物品的字典。每个键是物品的资产 ID,作为字符串表示,每个键的值是一个 物品。此函数只能从 Script 中调用。

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
local items = MerchBooth.getItems()
print(items)
end

removeItem

removeItem(assetId: number)

注销以前通过 addItemAsync 添加的物品,移除其在目录视图中的瓦片及任何分配给它的 接近提示。此函数只能从 Script 中调用。

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
-- 一段时间后移除物品
task.wait(5)
MerchBooth.removeItem(4819740796)
end

addProximityButton

addProximityButton(adornee: BasePart|Model|Attachment, assetId: number)

在给定的 adornee 上添加一个 接近提示,该提示将触发显示物品的购买视图,前提是其资产 ID。可以作为 3D 环境中的 2D 目录视图的替代,鼓励玩家发现物品。

注意,必须通过 addItemAsync 添加物品后,才能分配接近按钮。另请参见 removeProximityButton 以从对象中移除接近提示。

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
local item = Workspace:FindFirstChild("Robox")
if item then
MerchBooth.addProximityButton(item, 4819740796)
end
end

removeProximityButton

removeProximityButton(adornee: BasePart|Model|Attachment)

移除通过 addProximityButton 生成的 接近提示。此函数只能从 Script 中调用。

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
local item = Workspace:FindFirstChild("Robox")
if item then
MerchBooth.addProximityButton(item, 4819740796)
end
-- 一段时间后移除提示
task.wait(5)
MerchBooth.removeProximityButton(item)
end

setCatalogSort

setCatalogSort(sortFunction: function): boolean

设置要在目录视图中使用的排序函数 sortFunction。提供的排序函数可以使用基于 物品 信息(例如 pricetitle)的逻辑。此函数只能从 LocalScript 中调用。

以下是对目录进行排序的一些示例:

价格从低到高

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setCatalogSort(function(a, b)
return a.price < b.price
end)
价格从高到低

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setCatalogSort(function(a, b)
return a.price > b.price
end)
价格从低到高和按字母顺序

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setCatalogSort(function(a, b)
return if a.price == b.price then a.title < b.title else a.price < b.price
end)

setControlKeyCodes

setControlKeyCodes(control: MerchBooth.Controls, keyCodes: table)

配置与商品摊位交互的键和按钮值。第一个参数必须是一个 MerchBooth.Controls 枚举,第二个参数是一个包含 keyboard 和/或 gamepad 的表,及对应的 Enum.KeyCode 枚举。

枚举(control默认 keyCodes 键/值
MerchBooth.Controls.ProximityPromptskeyboard = Enum.KeyCode.E
gamepad = Enum.KeyCode.ButtonY
MerchBooth.Controls.OpenMerchBoothgamepad = Enum.KeyCode.ButtonY
MerchBooth.Controls.CloseMerchBoothgamepad = Enum.KeyCode.ButtonB
MerchBooth.Controls.Filtergamepad = Enum.KeyCode.ButtonX
MerchBooth.Controls.ViewItemgamepad = Enum.KeyCode.ButtonA
LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setControlKeyCodes(MerchBooth.Controls.ProximityPrompts, {
keyboard = Enum.KeyCode.Q,
gamepad = Enum.KeyCode.ButtonL1,
})

openMerchBooth

openMerchBooth()

打开商品摊位窗口(如果关闭)并导航至目录视图。此函数只能从 LocalScript 中调用。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(assetId)
end)
if not success then
warn(errorMessage)
end
MerchBooth.openMerchBooth()

openItemView

openItemView(itemId: number)

导航到给定 itemId 的单个物品视图,打开商品摊位窗口(如果目前关闭)。此函数只能从 LocalScript 中调用。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
MerchBooth.openItemView(4819740796)
end

toggleCatalogButton

toggleCatalogButton(enabled: boolean)

在屏幕右侧切换目录按钮的开启/关闭。这在实现 自定义按钮 或将商品摊位的显示限制在 区域接近提示 时很有用。只能从 LocalScript 调用。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.toggleCatalogButton(false)

isMerchBoothOpen

isMerchBoothOpen(): Tuple

如果目录或物品视图打开,则返回 true。如果物品视图打开,则返回物品的资产 ID 作为第二个值。此函数只能从 LocalScript 调用。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
MerchBooth.openItemView(4819740796)
local isOpen, itemId = MerchBooth.isMerchBoothOpen()
print(isOpen, itemId)
end

closeMerchBooth

closeMerchBooth()

关闭商品摊位窗口。此函数只能从 LocalScript 中调用。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.closeMerchBooth()

isMerchBoothEnabled

isMerchBoothEnabled(): boolean

此函数可以与 setEnabled 一起使用,以检查商品摊位当前是否启用。只能从 LocalScript 调用。

setEnabled

setEnabled(enabled: boolean)

设置整个商品摊位是否启用。当禁用时,此函数会移除整个 UI,包括 接近提示,并断开所有 事件。此函数只能从 LocalScript 调用。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local isEnabled = MerchBooth.isMerchBoothEnabled()
if isEnabled then
MerchBooth.setEnabled(false)
end

事件

itemAdded

在通过 addItemAsync 添加物品时触发。此事件只能在 Script 中连接。

参数
assetId: number物品资产 ID。
itemInfo: table包含 物品 信息(例如 pricetitle)的字典。
Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemAdded:Connect(function(assetId, itemInfo)
print("物品添加,资产 ID 为", assetId)
print(itemInfo)
end)

itemRemoved

在通过 removeItem 移除物品时触发。此事件只能在 Script 中连接。

参数
assetId: number物品资产 ID。
Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemRemoved:Connect(function(assetId)
print("物品移除,资产 ID 为", assetId)
end)

merchBoothOpened

在目录 物品详细视图打开时触发。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.merchBoothOpened:Connect(function()
print("摊位视图已打开")
end)

merchBoothClosed

在目录 物品详细视图关闭时触发。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.merchBoothClosed:Connect(function()
print("摊位视图已关闭")
end)

catalogViewOpened

在目录视图打开时触发。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.catalogViewOpened:Connect(function()
print("目录视图已打开")
end)

catalogViewClosed

在目录视图关闭时触发。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.catalogViewClosed:Connect(function()
print("目录视图已关闭")
end)

itemViewOpened

在物品详细视图打开时触发。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemViewOpened:Connect(function()
print("物品视图已打开")
end)

itemViewClosed

在物品详细视图关闭时触发。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemViewClosed:Connect(function()
print("物品视图已关闭")
end)
©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。