I've made a script that allows players to enter a catalog ID and either purchase or wear the item. Currently, players can purchase items but not wear them. The following is the code I've been attempting to use to place items onto players. For simplicities sake, the only code for putting items on is for pants, but even that is off.
local wear = script.Parent.Parent.WearButton
local player = game.Players.LocalPlayer
wear.MouseButton1Click:connect(function()
local Id = script.Parent.Text
local assetID = ("rbxassetid://"..Id) --asset link
local avatarchange = player:GetChildren()-- Getting the children of player
print ("Got to this part at least! and the id link is "..assetID) -- The furthest the code is run
for i,v in pairs (avatarchange) do
if (v.ClassName == "Pants") then
print("Got to finding Pants")
v.PantsTemplate = assetID
print("Pants have been succesfully worn")
end
end
end)
There are no errors that pop up, but it simply does not run. The three things I'm sure about is:
- I most likely used the for function wrong
- I most likely need multiple if statements for whether the ID is accessory, shirt or pants.
- The accessories (from what I've seen), need weldfunctions. I've looked and am not quite sure how to implement this into the code.
Please, if you end up showing a proper script for this, explain it because this is in the realm that I have no expertise in.

2 comments
Are you using a server script or local script? And you might have to own the clothing but I don't know.
It's local script. I believe you don't need to own the clothing because it's literally grabbing ID's off the catalog itself and not within a group.