Try clothes on in studio

How can I make a script where players can try on clothes. For example the games where you can buy clothes and then you automatically have them. Every single time I try to do it I fail and the player’s pants are gone. Here is an attempt:

local PPS = game:GetService("ProximityPromptService")
local Main = require(script.Parent:WaitForChild("ModuleScript"))

PPS.PromptTriggered:Connect(function(prox, plr)
	Main.HandleLocker(prox, plr)
end)

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local shirt = char:WaitForChild("Shirt")
		local pant = char:WaitForChild("Pants")
		
		task.wait(2)
		
		pant.PantsTemplate = "http://www.roblox.com/asset/?id=398633812"
	end)
end)

Are you using the actual assetId, or the Roblox link?

Try the following: http://www.roblox.com/asset/?id=398633811 for the PantsTemplate property. (I inserted 398633812 into PantsTemplate and then Roblox automatically gives you the AssetId and not the Roblox link.)

Also it may be becayse you’re doing local pant = char:WaitForChild("Pants"), if the player doesn’t have any pants equip that will yield forever as they don’t have any pants on. To counteract this you could use :FindFirstChild to see if they have pants, if they don’t you could create new pants, parent to the character, and then add the assetId to the pants.

Yes this worked. Somehow changing the number by 1 works. Care to explain?

Well, not always. It depends on the actual asset id of the clothing. When you upload a piece of clothing to the platform, two main things are generated.

  • The actual shirt, which you can sell. When you go on the shirt catalog you see this.
  • As well as the actual asset id of the shirt. The asset id of the shirt is what controls what the shirt actually looks like.

In the case of yours, the asset id was just one away but this isn’t always the case. If you want to find the asset Id, in studio, paste the shirt id / pant id (not the full link, just the ID) into a shirt / pant object. Roblox will automatically translate this to the asset id, however in a script, you’re setting a direct value meaning this won’t actually occur.

I’ve been told I’m pretty bad at explaining things, so if you’re still confused let me know, or possibly someone else can chime in if you don’t understand.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.