Shirt ID not changing correctly

I’m experiencing some issues with my code for a Shirt Locker System, with this, the ShirtId changes within the player’s character’s shirt but the shirt does not properly appear and makes them go naked.

Please help me.

local event = game.ReplicatedStorage.LockerEvents:WaitForChild("ChangeShirt")
local shirtIdObject = script.Parent:WaitForChild("ShirtID")

script.Parent.MouseButton1Click:Connect(function()
	local Id = script.Parent.ShirtID.Value
	event:FireServer(Id)
end)

2nd script

local event = game.ReplicatedStorage.LockerEvents:WaitForChild("ChangeShirt")
event.OnServerEvent:Connect(function(player, shirtId)
	local character = player.Character
	if character then
		local Shirt = character:FindFirstChild("Shirt")
		if not Shirt then
			Shirt = Instance.new("Shirt")
			Shirt.Parent = character
			warn("[WARNING]: NO SHIRT FOUND, CREATING NEW")
		end
		Shirt.ShirtTemplate = "rbxassetid://" .. shirtId
	else
		warn("[WARNING]: NO CHARACTER FOUND")
	end
end)

I’ve tried re-coding it multiple times but nothing has been working out. If anyone could help that’d be fantastic.

Photo:

No errors or anything showing up with warnings in the output.

Make sure your shirtID is the ID of the shirt template and not just the shirt. In Roblox studio, if you past the shirt ID into the ShirtTemplate property of the Shirt instance, it’ll automatically convert the shirt ID to the shirt template’s ID, but in scripting it doesn’t do this.

That is assuming that the shirtID is the problem.

The clothing just doesn’t appear, that’s the issue.

What I meant was that the clothing doesn’t appear because the shirtID variable in your script is incorrect… and that shirtID variable may be incorrect because you’re using the ID of the shirt and not the shirt template

Sorry if I was confusing. If you want to change the player’s character’s shirt, I suggest using InsertService to insert the shirt, which you can use the ShirtID/ContentID for (this does not use shirt template ID).

Using the method I just described, this was my code for getting a shirt based on ShirtID

--local varaibles that you should change to be specific to your script
local shirtAssetID = --the shirt asset ID
local character = --the player's character
	
--Using InsertService to get a model that'll contain the shirt. This way we don't have to worry about change Shirt.ShirtTemplate
local model = game:GetService("InsertService"):LoadAsset(shirtAssetId)
local newShirt = model:FindFirstChildOfClass("Shirt")

--Get rid of the player's character's old shirt if there is one
local oldShirt = character:FindFirstChild("Shirt")
if oldShirt then
	oldShirt:Destroy()
end

--put on the new shirt onto the character
newShirt.Parent = character
model:Destroy()
1 Like