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ẻ và 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:
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.

Đả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.

Tìm và nhấp vào ô Gói.
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.

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:
Trong StarterPlayerScripts, tạo một LocalScript mới và đổi tên thành Cấu hìnhQuầyHàngMerch.

Dán mã sau đây vào script mới.
LocalScript - ConfigureMerchBoothlocal 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ẻ và 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.
Tạo một Script trong ServerScriptService và dán mã sau đây.
Script - Add Avatar Assetslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local items = {}for _, assetId in items dolocal success, errorMessage = pcall(function()MerchBooth.addItemAsync(assetId)end)if not success thenwarn(errorMessage)endendSao 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 Roblox là 607702162.

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 Assetslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local items = {607702162, -- Mũ bóng chày Roblox4819740796, -- Robox1374269, -- Tai mèo11884330, -- Kính nerd10476359, -- Mũ giấy}for _, assetId in items dolocal success, errorMessage = pcall(function()MerchBooth.addItemAsync(assetId)end)if not success thenwarn(errorMessage)endend
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.
Tạo một Script trong ServerScriptService và dán mã sau đây.
Script - Add Passeslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local items = {}for _, assetId in items dolocal success, errorMessage = pcall(function()MerchBooth.addItemAsync(assetId)end)if not success thenwarn(errorMessage)endendĐiều hướng đến Bảng điều khiển Nhà sáng tạo và chọn trải nghiệm.
Trong cột bên trái, dưới Kiếm tiền, chọn Thẻ.
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.

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 và 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 Passeslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local items = {4343758, -- Giáp ColdFyre28521575, -- Khiên Slime}for _, assetId in items dolocal success, errorMessage = pcall(function()MerchBooth.addItemAsync(assetId, Enum.InfoType.GamePass)end)if not success thenwarn(errorMessage)endend
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.
Tạo một Script trong ServerScriptService và dán mã sau đây.
Script - Add Developer Productslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local items = {}for _, assetId in items dolocal success, errorMessage = pcall(function()MerchBooth.addItemAsync(assetId)end)if not success thenwarn(errorMessage)endendĐiều hướng đến Bảng điều khiển Nhà sáng tạo và chọn trải nghiệm.
Trong cột bên trái, dưới Kiếm tiền, chọn Sản phẩm phát triển.
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.

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 và 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 Productslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local items = {1236602053, -- Làm đầy Mana1257880672, -- Thuốc hồi phục}for _, assetId in items dolocal success, errorMessage = pcall(function()MerchBooth.addItemAsync(assetId, Enum.InfoType.Product)end)if not success thenwarn(errorMessage)endend
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:
Tạo một nút mới như được chỉ ra trong Nút.
Tạo một LocalScript làm trẻ của đối tượng nút.

Dán mã sau đây vào script mới.
LocalScript - Custom Catalog Buttonlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)-- Gỡ bỏ nút danh mục mặc địnhMerchBooth.toggleCatalogButton(false)-- Kết nối nút tùy chỉnhscript.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:
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 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ó.
Đặ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 CanCollide và CanQuery 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ó.


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

Trong script mới, dán mã sau giải sử dụng các sự kiện Touched và TouchEnded để phát hiện khi nhân vật vào/rời khỏi khu vực và gọi openMerchBooth và closeMerchBooth để mở/đóng GUI quầy hàng.
LocalScriptlocal 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 địnhMerchBooth.toggleCatalogButton(false)local function setupRegion(region: BasePart)region.Touched:Connect(function(otherPart)local character = Players.LocalPlayer.Characterif character and otherPart == character.PrimaryPart thenMerchBooth.openMerchBooth()endend)region.TouchEnded:Connect(function(otherPart)local character = Players.LocalPlayer.Characterif character and otherPart == character.PrimaryPart thenMerchBooth.closeMerchBooth()endend)end-- Duyệt qua các khu vực cửa hàng đã được gán nhãnfor _, region in CollectionService:GetTagged("ShopRegion") dosetupRegion(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àoCollectionService: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 - ConfigureMerchBoothlocal 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.SpheremyParticleEmitter.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ả ScreenGuis và CoreGuis 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 - ConfigureMerchBoothlocal 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 - ConfigureMerchBoothlocal 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óa | Loại | Mô tả |
|---|---|---|
| assetId | số | ID danh mục của mục, như đã được truyền cho addItemAsync. |
| title | chuỗi | Tiêu đề của mục như nó xuất hiện trong danh mục. |
| price | số | Giá của mục tính bằng Robux. |
| description | chuỗi | Mô tả của mục như nó xuất hiện trong danh mục. |
| assetType | chuỗi | Chuỗi đại diện cho loại phụ kiện của mục. |
| isOwned | bool | Xác định liệu người chơi hiện tại có sở hữu mục hay không. |
| creatorName | chuỗi | Tên nhà sáng tạo của mục được hiển thị trong danh mục. |
| creatorType | Enum.CreatorType | Loạ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ên | Tóm tắt |
|---|---|
| ProximityPrompts | Phí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. |
| OpenMerchBooth | Phím và/hoặc nút gamepad để mở quầy hàng merch. |
| CloseMerchBooth | Phím và/hoặc nút gamepad để đóng quầy hàng merch. |
| Filter | Phí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. |
| ViewItem | Phím và/hoặc nút gamepad để mở chế độ xem một mục quầy hàng cụ thể. |
LocalScriptlocal 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óa | Mô tả | Mặc định |
|---|---|---|
| backgroundColor | Màu nền chính của cửa sổ (Color3). | [0, 0, 0] |
| cornerRadius | Bán kính góc cho cửa sổ chính (UDim). | (0, 16) |
| cornerRadiusSmall | Bán kính góc cho các phần tử bên trong cửa sổ (UDim). | (0, 8) |
| textFont | Phông chữ của "văn bản chính" như giá cả, mô tả và thông tin khác (Enum.Font). | Gotham |
| textSize | Kích thước của văn bản chính. | 14 |
| textColor | Màu của văn bản chính (Color3). | [255, 255, 255] |
| secondaryTextColor | Màu được sử dụng cho một số biến thể của văn bản chính (Color3). | [153, 153, 158] |
| headerFont | Phông chữ của văn bản tiêu đề dùng cho tiêu đề cửa sổ (Enum.Font). | GothamMedium |
| headerTextSize | Kích thước của văn bản tiêu đề dùng cho tiêu đề cửa sổ. | 18 |
| titleFont | Phô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 |
| titleTextSize | Kí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 |
| buttonColor | Mà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] |
| buttonTextColor | Mà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] |
| secondaryButtonColor | Mà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] |
| secondaryButtonTextColor | Mà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] |
| inactiveButtonColor | Mà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] |
| inactiveButtonTextColor | Mà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] |
| particleEmitterTemplate | Thể hiện tùy chỉnh của ParticleEmitter tùy chọn xuất hiện và phát khi trang bị. |
LocalScriptlocal 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ản và thẻ 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.ProximityPrompts | keyboard = Enum.KeyCode.E gamepad = Enum.KeyCode.ButtonY |
| MerchBooth.Controls.OpenMerchBooth | gamepad = Enum.KeyCode.ButtonY |
| MerchBooth.Controls.CloseMerchBooth | gamepad = Enum.KeyCode.ButtonB |
| MerchBooth.Controls.Filter | gamepad = Enum.KeyCode.ButtonX |
| MerchBooth.Controls.ViewItem | gamepad = Enum.KeyCode.ButtonA |
LocalScriptlocal 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.
LocalScriptlocal 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.
LocalScriptlocal 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.
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local MerchBooth = require(ReplicatedStorage.MerchBooth)local isEnabled = MerchBooth.isMerchBoothEnabled()if isEnabled thenMerchBooth.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.
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: number | ID 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)