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

Spawn a model with a script?

Asked by 9 years ago

Is it possible to spawn a model with a script?

Model: http://www.roblox.com/FC-item?id=247458463

3 answers

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

What You Need

For this you need to use InsertService with the LoadAsset function. The LoadAsset function takes one argument, which should be the mode ID that you want to insert.

Limitations

The model being inserted has to be owned by either of the two;

  • The Developer of the game it is being inserted into
  • ROBLOX

Code

So, for your purposes.. your ID is 247458463, so we'll use the LoadAsset function with that as the arguments.

--First, load the model.
local model = game:GetService('InsertService'):LoadAsset(247458463)
--Now, since the model is nil at this point, parent it.
model.Parent = workspace

NOTE: The model inserted will be inside of a model object upon insert. So say you insert a script and use the method above, you have to index 'model' for the script

1
Hypocrite. You said you didn't have to own the model for it to be inserted. yumtaste 476 — 9y
0
Well I'm sure "ROBLOX" owns the model stated in the example the OP provided. Lacryma 548 — 9y
Ad
Log in to vote
1
Answered by
yumtaste 476 Moderation Voter
9 years ago

Yes, it is possible. Use InsertService.

local insertService = game:GetService("InsertService")
local modelId = 42069 --change this to the model ID, the string of numbers at the end of a model's link

local model = insertService:LoadAsset(modelId)
model.Parent = workspace

Please note that you need to own the model to be able to insert it from scripts in-game, as stated here.

0
I legit did not notice you answered xd Lacryma 548 — 9y
0
You don't have to own the model for it to be inserted.. Goulstem 8144 — 9y
0
It says so on the wiki. Please go to the link, although I haven't used InsertService in my own scripts. yumtaste 476 — 9y
Log in to vote
0
Answered by
Lacryma 548 Moderation Voter
9 years ago

game:GetService("InsertService"):LoadAsset(247458463).Parent = workspace

You must own or have the model.

0
You don't have to own the model for it to be inserted.. Goulstem 8144 — 9y

Answer this question