语法
GetObjects(context: DataModel, asset: string): { Instance }参数
| 名称 | 类型 | 描述 |
|---|---|---|
context | DataModel | Method-call self value. Use game:GetObjects(asset). |
asset | string | Asset 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