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

How can I insert a model via script?

Long story short, I need this for something special.

1 answer

✓ Accepted answer

What You Need

The LoadAsset function of InsertService

The LoadAsset function takes in arguments of the model ID that you're importing. If you pass all the prerequisites(which I will state) then it returns a model instance, your model that you're importing is inside of this model.

NOTE: The model is initially nil, you have to parent it to workspace for it to show up. (Credit to LordDragonZord) You can either do this by directly setting the Parent property of the model, or using the Insert function of InsertService.. which basically just does the same thing as the former.


Prerequisites of LoadAsset

The model has to be either owned by;

  • The owner of the game you're importing to

  • The ROBLOX account



Code

local is = game:GetService('InsertService')
local id = 00000000 --ID of model to import

local model = is:LoadAsset(id)
model.Parent = workspace

--Or (Credit to LordDragonZord)

is:Insert(model)

3 comments

1

The model's parent is nil, but you could just do is:Insert(model) instead of model.Parent = workspace for line 5

0

Thanks for pointing that out(: Credited you.

0

I'm so special :3333333333333

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