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

I can't figure out how to make a gui that you place the id and it places the clothing?

I am working on a My Hero Academia RP Game and I need to make a gui that gives clothing after the placing of a ID I need some help

1 answer

✓ Accepted answer

You can use the LoadAsset function.

https://developer.roblox.com/en-us/api-reference/function/InsertService/LoadAsset

Here is a simple sample script:

local textbox = -- your textbox
local InsertService = game:GetService("InsertService") -- gets the inserting service
local id = tonumber(textbox.Text) -- changing it to a number just in case lol
local asset
local model, errormsg = pcall(function() -- use a pcall to determine if the model exists
	asset = InsertService:LoadAsset(id) -- loads the asset by the id
end)

if model then -- if it does exist
	-- You can just parent the asset to the player, aka...
	asset.Parent = character -- your player's character
	-- Or you can check if it is a shirt first (i haven't tested this so idk if it will work)
	asset.Parent = workspace -- parent so that it does not return nil
	if asset:IsA("Shirt") then -- is it a shirt??
		asset.Parent = character -- your player's character
	else -- its not a shirt :(
		warn("assetId did not return a shirt") -- warning to the output
	end
else -- it doesn't exist
	warn("error loading asset")
end

Here is info for pcall() and other lua globals https://developer.roblox.com/en-us/api-reference/lua-docs/Lua-Globals

Hope this leads you in the right direction

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