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

How can a model get created if a GUI is clicked?

I'm currently making a game that heavily uses TextButton GUIs and ImageButton GUIs. How can I get a model to be placed into the game if an ImageButton GUI is clicked?

1 answer

I assume your model is uploaded on the website. And that the script is a child of the ImageButton


script.Parent.MouseButton1Click:connect(function()

local Id = 1  -- Replace 1 with your model Id.
game:GetService("InsertService"):LoadAsset(Id).Parent = game.Workspace

script.Parent.Active = false
end)

9 comments

0

I put the script in the ImageButton but the model didn't appear anywhere in the game when I clicked it. Any help?

0

Are you sure the model is in your inventory & that you typed the Id correctly?

0

The model is definitely in my inventory, and I copied & pasted the ID correctly.

0

Hmm this is tricky, are you the creator of the model?

0

Yes, I am the creator. Would it make a difference if it was a LocalScript instead?

0

Maybe try it.

0

It still doesn't work.

0

Ok, I checked the ROBLOX Wiki and it turns out it is assetID instead of ID. It works now. Thanks for the help anyway.

0

Sorry my bad, you need to set the parent of the inserted object, i forgot that.

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