getobjects Asynchronous
Load Instances from an asset URL through the DataModel’s GetObjects method. Use it when your script needs the objects inside an asset rather than only its ID.
Luau
getobjects(asset: string) -> {Instance}
getobjects(game: DataModel, asset: string) -> {Instance}Parameters · overload 1
| Parameter | Type | Description |
|---|---|---|
asset | string | Asset URL or identifier accepted by game:GetObjects. |
Parameters · overload 2
| Parameter | Type | Description |
|---|---|---|
game | DataModel | DataModel receiver for the alternate game-first call form. |
asset | string | Asset URL or identifier accepted by game:GetObjects. |
Returns
{Instance}An array of loaded Instances; inspect and parent or destroy them yourself.
Usage notes
The wrapper delegates to the host method. Loading can fail, so handle errors and only use asset IDs you intend to load.
Example
Luau
-- Replace this with an asset ID you own or trust.
local asset = "rbxassetid://YOUR_ASSET_ID"
local ok, objects = pcall(getobjects, asset)
if ok then
for _, object in ipairs(objects) do
print(object.ClassName, object.Name)
object:Destroy()
end
else
print("Asset could not be loaded:", objects)
end