PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Add Assets Using Code

Add Assets Using Code

Jun 23 2018, 2:02 AM PST

Problem

You want to insert a free model from a script, into your game.

Solution

Use the LoadAsset method.

game:GetService('InsertService'):LoadAsset(1234):GetChildren()[1].Parent = Workspace

Discussion

The LoadAsset method takes an argument of what the ID of the asset you’re trying to get. Make sure that the asset is in your models or else you won’t be able to use it. Then it returns a model with the inserted asset in it. To get the first member of this wrapping model I use GetChildren and index the first one. Then this gets parented to the Workspace.

Tags:
  • asset
  • model