Miscellaneous

GetObjects

Loads a local Roblox asset and returns a one-item table containing the loaded Instance.

语法

GetObjects(context: DataModel, asset: string): { Instance }

参数

名称类型描述
contextDataModelMethod-call self value. Use game:GetObjects(asset).
assetstringAsset string passed to Roblox local asset loading.

返回值

名称类型描述
objects{ Instance }Table whose first element is the loaded Instance.

说明

Loads a local Roblox asset and returns a one-item table containing the loaded Instance. Use the method-call form game:GetObjects(asset).

使用 2 个参数调用: context, asset。参数表会说明哪些值必填,哪些值只用于细化行为。

返回 objects ({ Instance })。使用返回表区分成功值、nil 结果和可恢复错误。

示例

Load a local asset through Roblox local asset loading and return it in a one-item table.

local objects = game:GetObjects("rbxassetid://123456789")
local object = objects[1]

if object then
    print(object.Name)
end