Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Getting a descendant of an object?

Asked by
RoyMer 301 Moderation Voter
6 years ago
Edited 6 years ago
local assetId = 1560601706
local instance = game:GetService("InsertService"):LoadAsset(assetId)
print(instance[1])

Why would this not work? Why doesn't it allow me to call the child of instance?

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

It's not a table, so you can't index it like that, however, you can use :GetChildren() and then index it.

local instance = game:GetService('InsertService'):LoadAsset(assetId):GetChildren()
print(instance[1]) -- Prints its name
0
Thanks boss RoyMer 301 — 6y
Ad

Answer this question