Shirt Change not working!

I wrote a script that is supposed to change the character’s clothing when a button is pushed but instead of switching to the chosen outfits, the characters just become naked and no one wants that since this is a predominantly kids platform.

The script:

SuitUp.OnServerEvent:Connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Humanoid = Player.Character:FindFirstChild("Humanoid")
	local OriginalShirt = Character.Shirt.ShirtTemplate
	local OriginalPants = Character.Pants.PantsTemplate
	for _,v in pairs(Character:GetChildren()) do
		if v:IsA("Accessory") and not v.Handle:FindFirstChild("HairAttachment")then
			v.Handle.Transparency = 1
		end
	end
	Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=3282533924"
	Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=19843664501"
end)

How do I fix this?

2 Likes

Try changing the links to the templates like this: “rbxassetid://YOURIDHERE”. If that doesn’t works, try inserting a shirt instance and a pants instance in Replicated Storage, put their IDs, and when the button is clicked, change the parent of the shirt and pants. Also don’t forget to use Destroy() on the other shirt and pants instances, to make it not break.

Tried that, no results. I’ll try the second method and come back to you.

1 Like

But I want the script to remember the original shirt and pants id so that i can revert them in the suit down function. Which is a different function here:

SuitDown.OnServerEvent:Connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	for _,v in pairs(Character:GetChildren()) do
		if v:IsA("Accessory")then
			v.Handle.Transparency =0
		end
	end
end)

Why does it tell me that the pants don’t exist when i go to them on the catalog?

Oh really? Is it because it’s not a rbx link?

I even took the id and put it besides Catalog - Roblox and it said it doesn’t exist also you could put a folder and put a shirt and pants instance inside of the folder and set the ids when the players character is added inside of a server script. Like this.

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local newFolder = Instance.new("Folder") 
	newFolder.Name = "DefaultClothing"
	newFolder.Parent = Player
	local Shirt = Instance.new("Shirt")
	local Pants = Instance.new("Pants")
	Shirt.Parent = newFolder
	Pants.Parent = newFolder
	Player.CharacterAdded:Connect(function(Character)
		Shirt.ShirtTemplate = Character.Shirt.ShirtTemplate
		Pants.PantsTemplate = Character.Pants.PantsTemplate
	end)
end)

That’s not a template. That’s a shirt. You either have to find the template id or just use InsertService

He is right though, the pants don’t exist in any sort of link. I tried https://roblox.com/library/19843664501 too.

Im a man btw. Also to get the template for the shirt just put a shirt instance in your game and get the shirt id and put it as the template that will give you the template id which you can use to give the character a shirt.

lol that reply cracked me up for some reason.

I have no idea why the link isn’t working, i got the id from the avatar shop

You have to paste it MANUALLY to get the template id.

1 Like

This works all great and dandy EXCEPT according to @octav20071 I’ll have to destroy the original instances but I want the script to remember the original clothing ids so that I can revert them in the suit down function which is a seperate function on its own.

Is clothing an accessory? If so then you are also setting those to transparent.

No it’s not, it’s under clothing.

Thats what i said??? I said to paste it into the shirt template to get the shirt template that you can use for the character.

I said to destroy it because 2 shirts and 2 pants in the same rig could broke something, right?

Why would you have to destroy the original instances you can just change the shirt template and pants template of the shirt and pants inside of the character.

Why would there be 2 shirts and 2 pants inside of the same character?