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

Could instance.new spawn any models instead of blocks?

Asked by 2 years ago

Some examples is that you want to spawn a model every time someone clicks a button. If instance.new wouldn’t work then is there another way?

3 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Yes. There is a service named InsertService, and can be used to Insert Models, Meshes, etc.

Code for InsertService:

local InsertService = game:GetService("InsertService")
local id = -- your id --
local Model = InsertService:LoadAsset(id)
Model.Parent = workspace

If this doesn't work, alert me.

0
Thx Calvin20001 4 — 2y
0
Also this should be server sided if you want the changes to appear to everyone... so yea Finty_james 269 — 2y
Ad
Log in to vote
0
Answered by
Jo1nts 134
2 years ago

Cloning to be exact. Have whatever model you want to clone in Replicated Storage First, you would have your click event then inside the code you want to define your model and clone it like this:

local item = game.ReplicatedStorage.item
local clickDetector = script.Parent

local function spawnitem()
    local spawning = item:Clone()
    spawning.Parent = game.Workspace
end


clickDetector.MouseClick:Connect(function()
    spawnitem()
end)

Edit script if needed.

0
Also quick solution here also you can just connect the spawnitem function to the event Finty_james 269 — 2y
Log in to vote
0
Answered by
epoke466 100
2 years ago

You could put the module you want to insert in server storage and then copy/paste in this code into the script:

function insert ()
local copy = game.ServerStorage.InsertItemNameHere:Clone()
copy.parent = game.workspase
end

script.parent.MouseButton1Click:Connect(insert)

Answer this question