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

How can I spawn models?

Asked by 8 years ago

Hey sorry I am asking so many questions, but is it possible to spawn a whole model in a script, like how you create a Part but with a whole model, i.e. copy and pasting a whole model in a different position

0
Use MoveTo(position) on the model. HungryJaffer 1246 — 8y
0
That wasn't what I was meaning, I mean create a whole new model that is a copy of the other. zombie2u 0 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

Actually a lot simpler than you would think! All you really need is a Model id, a Part with a script in it. and http service. (BUT REMEMBER!!! The model you want to insert MUST be either for free or created by YOU!!!) This is roblox's way of preventing plagiarism! So let's get to the script!

note! 247223147 is just I model I made! you need to change the id to the model you made!

First off we need to gather the ID

local assetId = 247223147

This sets a variable for "assetid" which is an alias of the ID!

Next we need to gather the insert service!

Asset = game:GetService("InsertService"):LoadAsset(assetId)-- Asset is now our variable for the folllowing code. Loading the asset, assetid which is 247223147.

And our last essentials are the Parent, and the Position Let's call our inserted model "Inserted" But first!!! When you insert a service like a model, It will create a new Model and place the "Inserted" that you are inserting in that model. Like my model, Healing fairy is the name of the "inserted" INSIDE of the NEWLY created model. So make sure to change 'Healing fairy' in the folowing script to your model!

Asset.Parent = script.Parent--Without Parent, the model would be confused and will result in absoulutly nothing
Asset:FindFirstChild("Healing fairy"):MoveTo(script.Parent.Position)--script.Parent would be the part that the script is in. MoveTo is like setting a vector position for a part, but for a model.

THE FINISHED SCRIPT!!!

local assetId = 247223147 --Provides the actuall model
Asset = game:GetService("InsertService"):LoadAsset(assetId)--Loads the model
Asset.Parent = script.Parent--provides the Parent the child should be placed in.
Asset:FindFirstChild("Healing fairy"):MoveTo(script.Parent.Position)--Moves the model to the position of the part! --Make sure 'Position' is there or it won't work!
0
I wish I had enough rep to upvote thank you so much that helped a lot zombie2u 0 — 8y
0
Mark it as an answer. HungryJaffer 1246 — 8y
0
I always enjoy helping people! Your welcome! And as Hungryjaffer said, click the accept answer button! minikitkat 687 — 8y
Ad

Answer this question