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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by
Cesire 45
9 years ago

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

1script.Parent.MouseButton1Click:connect(function()
2 
3local Id = 1  -- Replace 1 with your model Id.
4game:GetService("InsertService"):LoadAsset(Id).Parent = game.Workspace
5 
6script.Parent.Active = false
7end)
0
I put the script in the ImageButton but the model didn't appear anywhere in the game when I clicked it. Any help? ToySackboyLBP2 0 — 9y
0
Are you sure the model is in your inventory & that you typed the Id correctly? Cesire 45 — 9y
0
The model is definitely in my inventory, and I copied & pasted the ID correctly. ToySackboyLBP2 0 — 9y
0
Hmm this is tricky, are you the creator of the model? Cesire 45 — 9y
View all comments (5 more)
0
Yes, I am the creator. Would it make a difference if it was a LocalScript instead? ToySackboyLBP2 0 — 9y
0
Maybe try it. Cesire 45 — 9y
0
It still doesn't work. ToySackboyLBP2 0 — 9y
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. ToySackboyLBP2 0 — 9y
0
Sorry my bad, you need to set the parent of the inserted object, i forgot that. Cesire 45 — 9y
Ad

Answer this question