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
✓ ANSWER ACCEPTED
I can't figure out how to make a gui that you place the id and it places the clothing?
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.
