How to give a player clothing

Honsestly, this seems like one of those things that seem so easy on paper then I try to do it then it just doesnt work out.

I am trying to delete the players shirt (If they have one) then create a new one. All I get it a new shirt instance but the shirt doesnt even show up. I made sure the id is valid. The id I used for this is 3670737444.

script.Parent.OnServerEvent:Connect(function(plr, itemtype, id) -- On server event
	if itemtype == "2DShirt" then -- If it should be changing shirt
		local hmd = plr.Character.Humanoid.HumanoidDescription -- humanoid desc
		local char = plr.Character -- character
		for i, v in pairs(char:GetChildren()) do -- deleting current shirt
			if v:IsA("Shirt") then
				v:Destroy()
			end
		end
		
		local s = Instance.new("Shirt") -- making new shirt
		s.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. id -- 3670737444
		s.Name = "Shirt" -- Naming the shirt
		s.Parent = char -- Setting the shirts parent
		hmd.Shirt = id -- Setting humanoid desc shirt to id
	end
end)

Explorer

Properties
image

script.Parent.OnServerEvent:Connect(function(plr) -- On server event
	if plr.Character:FindFirstChild("Shirt") then
plr.Shirt.ShirtTemplate = "rbxassetid://3670737444"
		end
	end
end)

i dont know if there’s too many or too little 'end’s so just play around with them until it works

1 Like

What if the player has no shirt on?

thats why there’s an “if” to check if they have one

if they do, it will change, if not, it wont

yeah but I need to give them a shirt whether they have one or not

script.Parent.OnServerEvent:Connect(function(plr) -- On server event
	if plr.Character:FindFirstChild("Shirt") then
		plr.Shirt.ShirtTemplate = "rbxassetid://3670737444"
	
	else
	local shirt = Instance.new("Shirt")
	shirt.Parent = plr
	shirt.ShirtTemplate = "rbxassetid://3670737444"
	
	end
end)

IDs you take from the browser link on the avatar shop don’t work if you put them in shirttemplate from a script. To get the real Id, that will work from a script, make a shirt in the studio itself, and put your link into it’s shirt template. You’ll notice that some numbers of the ID change. That’s the ID you need to use in the script

2 Likes

IDs you take from the browser link on the avatar shop don’t work if you put them in shirttemplate from a script. To get the real Id, that will work from a script, make a shirt in the studio itself, and p

that is exactly what I did

did you do it correctly? you need to insert a shirt into studio, and add the id from the catalog. it will change the id in the shirt template, copy that and use it in the script

Try to first parent your blank shirt instance to char, and only then insert ID

I’ll try again. http://www.roblox.com/asset/?id=3670737337 this is what it gives me.

if you go on that link, it says it doesn’t exist. usually they do exist after you put them into studio. can you send the original shirt id?

the link is not supposed to bring you to the website. It is just for studio only but this is the id: 3670737444

try putting the link in the script where it adds the shirt template

I think thats what I did? This is how it is supposed to look. But when I put the link in a script, it doesnt work.

i’m not sure why it isnt working then

didnt do anything unfortunately :\

Is the ID here referencing a string variable or a number? If it’s a number, you have to do

s.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. tostring(id)

If this doesn’t work, while in game, go to server view and screenshot me the hierarchy of your character, with the shirt selected so I can see the properties

Explorer

Properties
image

You want to give it to player, or dummy ? Because if you want to give it to every player, you can use game settings for it. In game settings, go to avatar, then scroll down to clothing section, select which clothing you want to overwrite and give it the ID if the clothing.

1 Like