Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with GetUsersSets method?[Not Fixed]

I was trying to print the names of the models in my set that I have by using GetUserSets method but I keep getting a error saying: Workspace.Script:8: attempt to index global 'Model' (a nil value)

InsertService = game:GetService("InsertService")
UserSets = InsertService:GetUserSets(1077607)
Set = UserSets[1] -- Think of this like a tablet Set 1 = 1 Set 2 = 2 and so on
SetId= Set.AssetSetId
Collection = InsertService:GetCollection(SetId)
for i = 1,10 do
Model = Collection[i]
AssestId = Model.AssestId
print(AssestId.Name)
end

Orginal Script:

InsertService = game:GetService("InsertService")
UserSets = InsertService:GetUserSets(1077607,1)
SetId= UserSets.AssetSetId
Collection = InsertService:GetCollection(SetId)
for i = 1,10 do
Model = Collection[i]
AssestId = Model.AssestId
print(Model.Name)
end

1 answer

✓ Accepted answer
InsertService = game:GetService("InsertService")
UserSets = InsertService:GetUserSets(1077607,1)
SetId= UserSets.AssetSetId
Collection = InsertService:GetCollection(SetId)
for i = 1,10 do
Model = Collection[i]
AssestId = Model.AssestId
print(Model.Name)
end

You have it a bit wrong here In order for UserSets to work what you are trying to do You need to do this

UserSets = InsertService:GetUserSets(1077607,1)
SetId= UserSets.AssetSetId
Collection = InsertService:GetCollection(SetId)
-- Change to
UserSets = InsertService:GetUserSets(1077607)
Set = UserSets[1] -- Think of this like a tablet Set 1 = 1 Set 2 = 2 and so on
SetId= Set.AssetSetId
Collection = InsertService:GetCollection(SetId)

2 comments

0

I changed to how you said and the names of model won't print.

0

Output: Workspace.Script:8: attempt to index global 'Model' (a nil value)

This discussion is preserved as it was. New answers, comments, and votes are closed.