Quầy hàng Merch

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.

Mô-đun Quầy hàng Merch nhà phát triển cho phép bạn cung cấp tài sản avatar, thẻsản phẩm phát triển để bán trực tiếp trong trải nghiệm của bạn. Người chơi có thể duyệt các mục, xem trước tài sản trên avatar của họ, mua các mục và ngay lập tức sử dụng hoặc trang bị chúng — tất cả đều mà không cần rời khỏi trải nghiệm của bạn. Điều này có thể giúp bạn kiếm tiền từ trải nghiệm của mình và thu lợi nhuận thông qua khoản phí 40% đối với việc bán các mặt hàng của các nhà sáng tạo khác.

Sử dụng mô-đun

Cài đặt

Để sử dụng mô-đun Quầy hàng Merch trong một trải nghiệm:

  1. Từ menu Cửa sổ của Studio hoặc trên thanh công cụ tab Trang chủ, mở Hộp công cụ và chọn tab Cửa hàng Nhà sáng tạo.

  2. Đảm bảo rằng sắp xếp Mô hình đã được chọn, sau đó nhấp vào nút Xem Tất cả cho các Danh mục.

  3. Tìm và nhấp vào ô Gói.

  4. Tìm mô-đun Quầy hàng Merch và nhấp vào nó hoặc kéo-thả nó vào chế độ xem 3D.

  5. Trong cửa sổ Khám phá, di chuyển toàn bộ mô-đun Quầy hàng Merch vào ReplicatedStorage. Khi trải nghiệm được chạy, mô-đun sẽ bắt đầu hoạt động.

Cấu hình

Mô-đun được cấu hình sẵn để hoạt động cho hầu hết các trường hợp sử dụng, nhưng nó có thể dễ dàng tùy chỉnh qua hàm configure. Ví dụ, để tạo một chủ đề nhẹ hơn và vô hiệu hóa nút Lọc mặc định trong khu vực trên bên trái của chế độ xem danh mục:

  1. Trong StarterPlayerScripts, tạo một LocalScript mới và đổi tên thành Cấu hìnhQuầyHàngMerch.

  2. Dán mã sau đây vào script mới.

    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
    })

Thêm mục

Quầy hàng merch là gì nếu không có hàng hóa? Các phần sau đây sẽ hướng dẫn bạn cách thêm tài sản avatar, thẻsản phẩm phát triển vào quầy hàng merch của bạn.

Tài sản avatar

Các mục như quần áo và phụ kiện phải được thêm thông qua ID tài sản của chúng, nằm trên trang chi tiết của mục trong Cửa hàng Avatar.

  1. Tạo một Script trong ServerScriptService và dán mã sau đây.

    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. Sao chép các ID tài sản mục từ URL trang web Cửa hàng Avatar. Ví dụ, ID của Mũ bóng chày Roblox607702162.

  3. Dán từng ID đã sao chép vào danh sách phân tách bằng dấu phẩy trong bảng items. Theo mặc định, các mục sẽ xuất hiện trong chế độ xem danh mục theo thứ tự bảng chữ cái, nhưng bạn có thể tùy chỉnh sắp xếp bằng cách sử dụng setCatalogSort.

    Script - Add Avatar Assets

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    607702162, -- Mũ bóng chày Roblox
    4819740796, -- Robox
    1374269, -- Tai mèo
    11884330, -- Kính nerd
    10476359, -- Mũ giấy
    }
    for _, assetId in items do
    local success, errorMessage = pcall(function()
    MerchBooth.addItemAsync(assetId)
    end)
    if not success then
    warn(errorMessage)
    end
    end

Thẻ

Việc thêm thẻ yêu cầu các ID thẻ có thể được tìm thấy trong Bảng điều khiển Nhà sáng tạo.

  1. Tạo một Script trong ServerScriptService và dán mã sau đây.

    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. Điều hướng đến Bảng điều khiển Nhà sáng tạo và chọn trải nghiệm.

  3. Trong cột bên trái, dưới Kiếm tiền, chọn Thẻ.

  4. Di chuột qua hình thu nhỏ của một thẻ, nhấp vào nút và chọn Sao chép ID Tài sản từ menu ngữ cảnh.

  5. Dán từng ID đã sao chép vào danh sách phân tách bằng dấu phẩy trong bảng items bao gồm Enum.InfoType.GamePass làm tham số thứ hai cho addItemAsync để chỉ ra rằng các mục là thẻ. Theo mặc định, các mục sẽ xuất hiện trong chế độ xem danh mục theo thứ tự bảng chữ cái, nhưng việc sắp xếp có thể được tùy chỉnh thông qua setCatalogSort.

    Script - Add Passes

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    4343758, -- Giáp ColdFyre
    28521575, -- Khiên Slime
    }
    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

Sản phẩm phát triển

Việc thêm sản phẩm phát triển yêu cầu các ID sản phẩm có thể được tìm thấy trong Bảng điều khiển Nhà sáng tạo.

  1. Tạo một Script trong ServerScriptService và dán mã sau đây.

    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. Điều hướng đến Bảng điều khiển Nhà sáng tạo và chọn trải nghiệm.

  3. Trong cột bên trái, dưới Kiếm tiền, chọn Sản phẩm phát triển.

  4. Di chuột qua hình thu nhỏ của một sản phẩm, nhấp vào nút và chọn Sao chép ID Tài sản từ menu ngữ cảnh.

  5. Dán từng ID đã sao chép vào danh sách phân tách bằng dấu phẩy trong bảng items bao gồm Enum.InfoType.Product làm tham số thứ hai cho addItemAsync để chỉ ra rằng các mục là sản phẩm phát triển. Theo mặc định, các mục sẽ xuất hiện trong chế độ xem danh mục theo thứ tự bảng chữ cái, nhưng bạn có thể tùy chỉnh sắp xếp bằng cách sử dụng setCatalogSort.

    Script - Add Developer Products

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    local items = {
    1236602053, -- Làm đầy Mana
    1257880672, -- Thuốc hồi phục
    }
    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

Nút danh mục tùy chỉnh

Theo mặc định, một nút danh mục ở bên phải cho phép người chơi mở quầy hàng bất kỳ lúc nào.

Trong một số trường hợp, có thể hữu ích để gỡ bỏ nút này và kết nối nút của riêng bạn:

  1. Tạo một nút mới như được chỉ ra trong Nút.

  2. Tạo một LocalScript làm trẻ của đối tượng nút.

  3. Dán mã sau đây vào script mới.

    LocalScript - Custom Catalog Button

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    -- Gỡ bỏ nút danh mục mặc định
    MerchBooth.toggleCatalogButton(false)
    -- Kết nối nút tùy chỉnh
    script.Parent.Activated:Connect(function()
    MerchBooth.openMerchBooth()
    end)

Khu vực có thể mua sắm

Một cách hữu ích để thúc đẩy việc mua sắm trong trải nghiệm của bạn là tự động hiển thị quầy hàng khi một người chơi vào một khu vực.

Để tạo một khu vực có thể mua sắm:

  1. Tạo một khối Anchored bao trùm khu vực phát hiện. Đảm bảo rằng khối đó đủ cao để va chạm với PrimaryPart của mô hình nhân vật (HumanoidRootPart theo mặc định).

    Khối để phát hiện khi người chơi tiếp cận phía trước của quầy hàng
  2. Sử dụng phần Thẻ trong thuộc tính của khối, áp dụng thẻ ShopRegion cho khối để CollectionService phát hiện nó.

  3. Đặt Transparency của phần đó ở mức tối đa để ẩn nó khỏi người chơi trong trải nghiệm. Ngoài ra, hãy vô hiệu hóa thuộc tính CanCollideCanQuery của nó để các vật thể không va chạm vật lý với nó và các raycast không phát hiện nó.

  4. Chèn một LocalScript mới vào dưới StarterPlayerScripts.

  5. Trong script mới, dán mã sau giải sử dụng các sự kiện TouchedTouchEnded để phát hiện khi nhân vật vào/rời khỏi khu vực và gọi openMerchBoothcloseMerchBooth để mở/đóng GUI quầy hàng.

    LocalScript

    local Players = game:GetService("Players")
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local CollectionService = game:GetService("CollectionService")
    local MerchBooth = require(ReplicatedStorage.MerchBooth)
    -- Gỡ bỏ nút danh mục mặc định
    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
    -- Duyệt qua các khu vực cửa hàng đã được gán nhãn
    for _, region in CollectionService:GetTagged("ShopRegion") do
    setupRegion(region)
    end
    -- Phát hiện khi các khu vực cửa hàng không truyền phát được truyền vào
    CollectionService:GetInstanceAddedSignal("ShopRegion"):Connect(setupRegion)

Nhắc nhở gần

Thay vì chế độ xem danh mục 2D, bạn có thể thêm nhắc nhở gần trên các đối tượng trong trải nghiệm. Điều này khuyến khích người chơi phát hiện các mục trong môi trường 3D, xem trước chúng trên avatar của riêng họ, mua chúng và ngay lập tức trang bị chúng. Xem addProximityButton để biết chi tiết.

Thay đổi hiệu ứng trang bị

Theo mặc định, quầy hàng merch hiển thị hiệu ứng lấp lánh chung khi một người chơi trang bị một mục từ đó. Để thay đổi hiệu ứng, hãy đặt particleEmitterTemplate thành một thể hiện của ParticleEmitter của riêng bạn trong một lệnh gọi configure.

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
})

Độ hiển thị GUI

Theo mặc định, quầy hàng merch ẩn tất cả ScreenGuisCoreGuis khi giao diện của nó xuất hiện, bao gồm trò chuyện, bảng xếp hạng và những thứ khác mà Roblox bao gồm. Nếu bạn muốn vô hiệu hóa hành vi này, hãy đặt hideOtherUis thành false trong một lệnh gọi configure.

LocalScript - ConfigureMerchBooth

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

Chuyển động nhân vật

Có thể có lợi khi ngăn một nhân vật di chuyển khi họ đang ở trong quầy hàng merch. Điều này có thể được thực hiện bằng cách đặt disableCharacterMovement thành true trong một lệnh gọi configure.

LocalScript - ConfigureMerchBooth

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

Tham chiếu API

Các loại

Mục

Các mục trong quầy hàng merch được đại diện bởi một từ điển với các cặp khóa-giá trị sau đây. Các mục có thể được tập hợp thông qua hàm getItems hoặc sự kiện itemAdded.

KhóaLoạiMô tả
assetIdsốID danh mục của mục, như đã được truyền cho addItemAsync.
titlechuỗiTiêu đề của mục như nó xuất hiện trong danh mục.
pricesốGiá của mục tính bằng Robux.
descriptionchuỗiMô tả của mục như nó xuất hiện trong danh mục.
assetTypechuỗiChuỗi đại diện cho loại phụ kiện của mục.
isOwnedboolXác định liệu người chơi hiện tại có sở hữu mục hay không.
creatorNamechuỗiTên nhà sáng tạo của mục được hiển thị trong danh mục.
creatorTypeEnum.CreatorTypeLoại nhà sáng tạo cho mục.

Các Enum

MerchBooth.Controls

Sử dụng cùng với setControlKeyCodes để tùy chỉnh các phím và nút gamepad cho việc tương tác với quầy hàng merch.

TênTóm tắt
ProximityPromptsPhím và/hoặc nút gamepad để mở chế độ xem mục khi các nhắc nhở gần được cấu hình.
OpenMerchBoothPhím và/hoặc nút gamepad để mở quầy hàng merch.
CloseMerchBoothPhím và/hoặc nút gamepad để đóng quầy hàng merch.
FilterPhím và/hoặc nút gamepad để sử dụng menu xổ xuống Lọc mặc định trong khu vực trên bên trái của chế độ xem danh mục.
ViewItemPhím và/hoặc nút gamepad để mở chế độ xem một mục quầy hàng cụ thể.
LocalScript

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

Các hàm

configure

configure(config: table)

Ghi đè các tùy chọn cấu hình phía khách mặc định thông qua các khóa/giá trị sau trong bảng config. Hàm này chỉ có thể được gọi từ một LocalScript.

KhóaMô tảMặc định
backgroundColorMàu nền chính của cửa sổ (Color3).[0, 0, 0]
cornerRadiusBán kính góc cho cửa sổ chính (UDim).(0, 16)
cornerRadiusSmallBán kính góc cho các phần tử bên trong cửa sổ (UDim).(0, 8)
textFontPhông chữ của "văn bản chính" như giá cả, mô tả và thông tin khác (Enum.Font).Gotham
textSizeKích thước của văn bản chính.14
textColorMàu của văn bản chính (Color3).[255, 255, 255]
secondaryTextColorMàu được sử dụng cho một số biến thể của văn bản chính (Color3).[153, 153, 158]
headerFontPhông chữ của văn bản tiêu đề dùng cho tiêu đề cửa sổ (Enum.Font).GothamMedium
headerTextSizeKích thước của văn bản tiêu đề dùng cho tiêu đề cửa sổ.18
titleFontPhông chữ của văn bản tiêu đề dùng cho tên mục trên trang chi tiết mục (Enum.Font).GothamBold
titleTextSizeKích thước của văn bản tiêu đề dùng cho tên mục trên trang chi tiết mục.28
buttonColorMàu nền cho các nút lớn hơn trong trạng thái có thể nhấp, chẳng hạn như nút mua chính trong chế độ xem mục (Color3).[255, 255, 255]
buttonTextColorMàu văn bản cho các nút lớn hơn trong trạng thái có thể nhấp, chẳng hạn như nút mua chính trong chế độ xem mục (Color3).[0, 0, 0]
secondaryButtonColorMàu nền cho các nút nhỏ hơn như nút giá trong chế độ xem danh mục hoặc nút Thử (Color3).[34, 34, 34]
secondaryButtonTextColorMàu văn bản cho các nút nhỏ hơn như nút giá trong chế độ xem danh mục hoặc nút Thử (Color3).[255, 255, 255]
inactiveButtonColorMàu nền cho tất cả các nút trong trạng thái không có thể nhấp (Color3).[153, 153, 158]
inactiveButtonTextColorMàu văn bản cho tất cả các nút trong trạng thái không có thể nhấp (Color3).[255, 255, 255]
particleEmitterTemplateThể hiện tùy chỉnh của ParticleEmitter tùy chọn xuất hiện và phát khi trang bị.
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)

Thêm một mục vào quầy hàng merch một cách không đồng bộ để nó đủ điều kiện để mua trong trải nghiệm. assetId là ID tài sản của mục, productType là enum Enum.InfoType của mục, và hideFromCatalog có thể được sử dụng để ẩn mục trong chế độ xem danh mục.

Xem Thêm Mục để biết chi tiết, vì việc sử dụng hơi thay đổi giữa tài sảnthẻ hoặc sản phẩm phát triển.

Script - Add Avatar Assets

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local items = {
607702162, -- Mũ bóng chày Roblox
4819740796, -- Robox
1374269, -- Tai mèo
11884330, -- Kính nerd
10476359, -- Mũ giấy
}
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, -- Giáp ColdFyre
28521575, -- Khiên Slime
}
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, -- Làm đầy Mana
1257880672, -- Thuốc hồi phục
}
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

Trả về một từ điển đại diện cho tất cả các mục hiện đang được đăng ký. Mỗi khóa là ID tài sản của một mục dưới dạng chuỗi, và mỗi giá trị của từng khóa là một Mục. Hàm này chỉ có thể được gọi từ một 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)

Hủy đăng ký một mục đã được thêm trước đó bằng cách sử dụng addItemAsync, xóa ô của nó trong chế độ xem danh mục và mọi nhắc nhở gần được gán cho nó. Hàm này chỉ có thể được gọi từ một Script.

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
local success, errorMessage = pcall(function()
MerchBooth.addItemAsync(4819740796)
end)
if success then
-- Sau một khoảng thời gian, xóa mục
task.wait(5)
MerchBooth.removeItem(4819740796)
end

addProximityButton

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

Thêm một nhắc nhở gần lên đối tượng adornee đã cho, sẽ kích hoạt hiển thị chế độ xem mua một mục, dựa trên ID tài sản của nó. Điều này có thể được sử dụng như một phương pháp thay thế cho chế độ xem danh mục 2D, khuyến khích người chơi phát hiện các mục trong môi trường 3D.

Lưu ý rằng một mục phải được thêm qua addItemAsync trước khi có thể gán một nút nhắc nhở gần cho nó. Xem thêm removeProximityButton để xóa nhắc nhở gần khỏi một đối tượng.

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)

Loại bỏ một nhắc nhở gần được tạo thông qua addProximityButton. Hàm này chỉ có thể được gọi từ một 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
-- Sau một khoảng thời gian, xóa nhắc nhở
task.wait(5)
MerchBooth.removeProximityButton(item)
end

setCatalogSort

setCatalogSort(sortFunction: function): boolean

Đặt hàm sắp xếp sortFunction sẽ được sử dụng trong chế độ xem danh mục. Hàm sắp xếp được cung cấp có thể sử dụng logic dựa trên thông tin Mục như price hoặc title. Hàm này chỉ có thể được gọi từ một LocalScript.

Dưới đây là một số ví dụ để sắp xếp danh mục:

Giá Từ Thấp Đến Cao

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setCatalogSort(function(a, b)
return a.price < b.price
end)
Giá Từ Cao Đến Thấp

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.setCatalogSort(function(a, b)
return a.price > b.price
end)
Giá Từ Thấp Đến Cao & Theo Bảng Chữ Cái

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)

Cấu hình các giá trị phím và nút cho việc tương tác với quầy hàng merch. Tham số đầu tiên phải là một enum MerchBooth.Controls và tham số thứ hai là một bảng chứa các phím keyboard và/hoặc gamepad cùng với các enum Enum.KeyCode tương ứng.

Enum (control)Giá trị mặc định keyCodes/Phím
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()

Mở cửa sổ quầy hàng merch (nếu bị đóng) và điều hướng đến chế độ xem danh mục. Hàm này chỉ có thể được gọi từ một 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)

Điều hướng đến chế độ xem một mục của ID itemId đã cho, mở cửa sổ quầy hàng merch nếu nó hiện đang đóng. Hàm này chỉ có thể được gọi từ một 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)

Bật/tắt nút danh mục bên phải màn hình. Điều này hữu ích khi triển khai một nút tùy chỉnh hoặc giới hạn sự xuất hiện của quầy hàng merch chỉ cho các vùng hoặc nhắc nhở gần. Chỉ có thể gọi từ một LocalScript.

LocalScript

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

isMerchBoothOpen

isMerchBoothOpen(): Tuple

Trả về true nếu hoặc là chế độ xem danh mục hoặc chế độ xem mục đang mở. Nếu chế độ xem mục đang mở, ID tài sản của mục sẽ được trả về dưới dạng giá trị thứ hai. Hàm này chỉ có thể được gọi từ một 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()

Đóng cửa sổ quầy hàng merch. Hàm này chỉ có thể được gọi từ một LocalScript.

LocalScript

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

isMerchBoothEnabled

isMerchBoothEnabled(): boolean

Hàm này có thể được sử dụng kết hợp với setEnabled để kiểm tra xem quầy hàng merch hiện có được bật hay không. Chỉ có thể gọi từ một LocalScript.

setEnabled

setEnabled(enabled: boolean)

Đặt liệu toàn bộ quầy hàng merch có được bật hay không. Khi bị vô hiệu hóa, hàm này sẽ xóa toàn bộ giao diện, bao gồm nhắc nhở gần, và ngắt kết nối mọi sự kiện. Hàm này chỉ có thể được gọi từ một LocalScript.

LocalScript

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

Sự kiện

itemAdded

Sẽ xảy ra khi một mục được thêm thông qua addItemAsync. Sự kiện này chỉ có thể được kết nối trong một Script.

Tham số
assetId: numberID tài sản của mục.
itemInfo: tableTừ điển thông tin Mục như price hoặc title.
Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemAdded:Connect(function(assetId, itemInfo)
print("Mục được thêm với ID tài sản là", assetId)
print(itemInfo)
end)

itemRemoved

Sẽ xảy ra khi một mục được xóa thông qua removeItem. Sự kiện này chỉ có thể được kết nối trong một Script.

Tham số
assetId: numberID tài sản của mục.
Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemRemoved:Connect(function(assetId)
print("Mục bị xóa với ID tài sản là", assetId)
end)

merchBoothOpened

Sẽ xảy ra khi chế độ xem danh mục hoặc chế độ xem chi tiết mục được mở.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.merchBoothOpened:Connect(function()
print("Chế độ xem quầy hàng đã mở")
end)

merchBoothClosed

Sẽ xảy ra khi chế độ xem danh mục hoặc chế độ xem chi tiết mục được đóng.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.merchBoothClosed:Connect(function()
print("Chế độ xem quầy hàng đã đóng")
end)

catalogViewOpened

Sẽ xảy ra khi chế độ xem danh mục được mở.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.catalogViewOpened:Connect(function()
print("Chế độ xem danh mục đã mở")
end)

catalogViewClosed

Sẽ xảy ra khi chế độ xem danh mục được đóng.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.catalogViewClosed:Connect(function()
print("Chế độ xem danh mục đã đóng")
end)

itemViewOpened

Sẽ xảy ra khi chế độ xem chi tiết mục được mở.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemViewOpened:Connect(function()
print("Chế độ xem mục đã mở")
end)

itemViewClosed

Sẽ xảy ra khi chế độ xem chi tiết mục được đóng.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MerchBooth = require(ReplicatedStorage.MerchBooth)
MerchBooth.itemViewClosed:Connect(function()
print("Chế độ xem mục đã đóng")
end)
©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.