Search code examples
luaassetsroblox

how to use InsertService:LoadAsset() with the name of model, not asset id?


I am working with the Roblox studio InsertService:LoadAsset() API witch can import models, decals, scripts, etc... I am trying to do the same(importing models and decals) just by the name of the model, not the id.

the code form @darkelementallord (roblox):

local ID = 0000000 --Change this to the model ID
local InsertService = game:GetService("InsertService") --Get the service

local Model = InsertService:LoadAsset(ID) --Insert the model
local NewModel = Model:GetChildren()[1] --Find your model

NewModel.Parent = workspace --Put it into the game
Model:Destroy() --Destroy the container model

Solution

  • You cannot load an Asset with InsertService just with the name of the Asset. You need the AssetId of the Asset to load it.