Script changing Shirt/Pants won't working

Hello developers!
I have made a tool that gives you a knight helmet and changes your outfit to middle age style’d outfit but the Shirts/Pants changing script won’t work and there are no errors, I tried using assets/contentprovidor.etc but nothing worked, here is the script:

Preview: https://gyazo.com/776a75716201ff131e8a0b25ccc3a882

Local script:

local AttireTool = script.Parent
local Wearing = false
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Pants = Character:WaitForChild("Pants")
local Shirt = Character:WaitForChild("Shirt")
local CurrentPants = Pants.PantsTemplate
local CurrentShirt = Shirt.ShirtTemplate
local AttireRequest = "DefaultAttire"
local Hum = Character:WaitForChild("Humanoid")
local EquipTrack = Hum:LoadAnimation(script:WaitForChild("Equip"))
local UnEquipTrack = Hum:LoadAnimation(script:WaitForChild("Unequip"))
local Event = game.ReplicatedStorage.Events.Attire

AttireTool.Activated:Connect(function()
	if Wearing then
		UnEquipTrack:Play()
		Event:FireServer(Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
		Wearing = not Wearing
	elseif not Wearing then
		EquipTrack:Play()
		Event:FireServer(Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
		Wearing = not Wearing
	end	
end)

Server script:

local ContentProvidor
local Event = game.ReplicatedStorage.Events.Attire
local DefaultAttire = game.ReplicatedStorage.Attires.Knight
local DefaultAttireShirt = "http://www.roblox.com/asset/?id=1488118250"
local DefaultAttirePants = "http://www.roblox.com/asset/?id=1487600311"

Event.OnServerEvent:Connect(function(plr, Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
	if AttireRequest == "DefaultAttire" and not Wearing then
		for _,Part in pairs(Character:GetChildren()) do
			if Part:IsA("Accessory") then
				local handle = Part.Handle
				handle.Transparency = 1
			end		
		end
		Shirt.ShirtTemplate = DefaultAttireShirt
		Pants.PantsTemplate = DefaultAttirePants
		local Head = Character.Head
		local CurrentAttire = DefaultAttire:Clone()
		local NewWeld = Instance.new("Weld")
		NewWeld.Part0 = CurrentAttire
		NewWeld.Part1 = Head
		NewWeld.Parent = CurrentAttire
		NewWeld.C0 = CFrame.new(0,-0.2,0)
		CurrentAttire.Parent = Head
	elseif AttireRequest == "DefaultAttire" and Wearing then
		for _,Part in pairs(Character:GetChildren()) do
			if Part:IsA("Accessory") then
				local handle = Part.Handle
				handle.Transparency = 0
			end		
		end
		Character.Head:FindFirstChild("Knight"):Destroy()
		Shirt.ShirtTemplate = CurrentShirt
		Pants.PantsTemplate = CurrentPants
	end	
end)

I am a little bit confused on your problem. So do u mean when the hat is worn on the player, the shirt doesn’t show up or when the player has no hat?

Cause it is a ShirtId, not a ShirtTemplateId.

here is your client code mistake you added player as an argument which you shouldnt do so it is automatically provided by roblox so try this code

local AttireTool = script.Parent
local Wearing = false
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Pants = Character:WaitForChild("Pants")
local Shirt = Character:WaitForChild("Shirt")
local CurrentPants = Pants.PantsTemplate
local CurrentShirt = Shirt.ShirtTemplate
local AttireRequest = "DefaultAttire"
local Hum = Character:WaitForChild("Humanoid")
local EquipTrack = Hum:LoadAnimation(script:WaitForChild("Equip"))
local UnEquipTrack = Hum:LoadAnimation(script:WaitForChild("Unequip"))
local Event = game.ReplicatedStorage.Events.Attire

AttireTool.Activated:Connect(function()
	if Wearing then
		UnEquipTrack:Play()
		Event:FireServer(Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
		Wearing = not Wearing
	elseif not Wearing then
		EquipTrack:Play()
		Event:FireServer(Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
		Wearing = not Wearing
	end	
end)

and also you added player as in 2 parameters here is a fix

local ContentProvidor
local Event = game.ReplicatedStorage.Events.Attire
local DefaultAttire = game.ReplicatedStorage.Attires.Knight
local DefaultAttireShirt = "http://www.roblox.com/asset/?id=1488118250"
local DefaultAttirePants = "http://www.roblox.com/asset/?id=1487600311"

Event.OnServerEvent:Connect(function(Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
	if AttireRequest == "DefaultAttire" and not Wearing then
		for _,Part in pairs(Character:GetChildren()) do
			if Part:IsA("Accessory") then
				local handle = Part.Handle
				handle.Transparency = 1
			end		
		end
		Shirt.ShirtTemplate = DefaultAttireShirt
		Pants.PantsTemplate = DefaultAttirePants
		local Head = Character.Head
		local CurrentAttire = DefaultAttire:Clone()
		local NewWeld = Instance.new("Weld")
		NewWeld.Part0 = CurrentAttire
		NewWeld.Part1 = Head
		NewWeld.Parent = CurrentAttire
		NewWeld.C0 = CFrame.new(0,-0.2,0)
		CurrentAttire.Parent = Head
	elseif AttireRequest == "DefaultAttire" and Wearing then
		for _,Part in pairs(Character:GetChildren()) do
			if Part:IsA("Accessory") then
				local handle = Part.Handle
				handle.Transparency = 0
			end		
		end
		Character.Head:FindFirstChild("Knight"):Destroy()
		Shirt.ShirtTemplate = CurrentShirt
		Pants.PantsTemplate = CurrentPants
	end	
end)

I don’t think I have the time to read this giant code, but did you first make it remove the original shirts and pants?

Not removing, just changing the original property’s id.

As @FlashFlame_Roblox said, ShirtId and ShirtTemplateId are two different things. You need to set it to the ShirtTemplateId and NOT the ShirtId. To get the ShirtTemplateId, just add a shirt to a dummy and paste the ShirtId in the box. Then as soon as you click enter, you will see a new set of numbers. That is the ShirtTemplateId.

Hope it helps.

2 Likes
Shirt.ShirtTemplate = DefaultAttireShirt
Pants.PantsTemplate = DefaultAttirePants

That’s exactly what am doing?

That literally broke my entire tool.

Basically, I’m changing players shirt template but it appears blank.

is the shirt like removed while changing Shirt:Destroy() or is the Id changed?

Not destroying and changing, just changing the ID.

hmm use the content provider service to load them first, and try that

I did try using CP and it didn’t work lol

Is that shirt like a “real” shirt, did u test on a dummy?

I did and the shirt worked on the testing dummy

is it possible for you to comment the script so I can take a look at whats happening?

Insert the pants and shirt you want using:

game:GetService("InsertService"):LoadAsset(ID).Parent = workspace

Then take the PantsTemplate/ShirtTemplate from these items, and replace

local DefaultAttireShirt
local DefaultAttirePants

with the shirt/pant templates.
Worked for me, hope it works for you.

You have to do it manually on a dummy in the Studio. When you pasted the Id in the script in, it will turn into a different one. And take that one and slap it on your script.

Don’t really understand what you meant by that.