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

How can I insert a model via script?

Asked by
wackem 50
9 years ago

Long story short, I need this for something special.

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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)
1
The model's parent is nil, but you could just do is:Insert(model) instead of model.Parent = workspace for line 5 EzraNehemiah_TF2 3552 — 9y
0
Thanks for pointing that out(: Credited you. Goulstem 8144 — 9y
0
I'm so special :3333333333333 EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question