学习
引擎类
MatchmakingService
无法创建
服务
未复制

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


概要
继承成员

API 参考
方法
GetServerAttribute
功能: Basic
MatchmakingService:GetServerAttribute(name:string):Tuple
参数
name:string
返回

InitializeServerAttributesForStudio
功能: Basic
MatchmakingService:InitializeServerAttributesForStudio(serverAttributes:Dictionary):Tuple
参数
serverAttributes:Dictionary
返回

SetServerAttribute
功能: Basic
MatchmakingService:SetServerAttribute(
name:string, value:Variant
参数
name:string
value:Variant
返回
代码示例
匹配服务示例
local MatchmakingService = game:GetService("MatchmakingService")
local RunService = game:GetService("RunService")
if RunService:IsStudio() then
-- 设置初始属性和测试模式的架构
MatchmakingService:InitializeServerAttributesForStudio({
Level = "高级",
Elo = 123.456,
TrainingMode = true
})
end
-- 检索 Level 属性
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("当前等级: " .. currentLevel)
end
-- 将 Level 属性值更新为高级
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "高级")
if not success then
warn("由于错误: " .. errorMessage .. ",未能将服务器属性 [Level] 更新为 [高级]")
else
print("成功将 [Level] 设置为 [高级]")
end

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。