Wear Shirt Script Not Working

It says "attempt to index nil with ‘ShirtTemplate’"
Id is a IntValue with the shirt Id (Yes, I made sure the Id is correct)
Thanks for any help!:ok_hand:
LOCAL SCRIPT

local Event = game.ReplicatedStorage.RemoteEvents.AvatarSystem.WearShirt

script.Parent.MouseButton1Click:Connect(function()
	Event:FireServer(script.Parent.Id.Value)
end)

SERVER SCRIPT

local Event = game.ReplicatedStorage.RemoteEvents.AvatarSystem.WearShirt

Event.OnServerEvent:Connect(function(player,Value)
	player:FindFirstChild("Shirt").ShirtTemplate = "rbxassetid://" ..Value
end)

use the players character and not the player itself.

local Event = game.ReplicatedStorage.RemoteEvents.AvatarSystem.WearShirt

Event.OnServerEvent:Connect(function(player,Value)
	player.Character:FindFirstChild("Shirt").ShirtTemplate = "rbxassetid://" ..Value
end)
1 Like

Value is a number value, which you’re trying to add with a string value. Try this instead:

player.Character:FindFirstChild("Shirt").ShirtTemplate = "rbxassetid://" ..tostring(Value)
4 Likes

No errors anymore but it just takes my shirt off and doesn’t put the new one on

Are you sure that the shirt you want to add is available? I wouldn’t know what else is wrong.

1 Like

Yep, I’ve tried a few different Ids and they work when I manually go into my avatar model in studio and change the ShirtTemplate

Would you mind showing me what the ShirtTemplate property has for a value when you try different clothes.

Try printing the id to see if it’s already included with the rbx link.

print(script.Parent.Id.Value)

Welp, now it doesn’t load when I do it manually either

Nope, no link. Just the number

If you’ve tried the other post’s solutions and it still did not work, make sure that the shirt id is actually a template. On the roblox main page go to “Create” at the top of your screen then “Library” then click on any model. At the url link at the top of the page, you’ll see a spot with numbers. Replace that with your asset id and make sure the shirt is a template.

image

Also make sure to put:

player.Character:FindFirstChild("Shirt").ShirtTemplate = "rbxassetid://" ..tostring(Value)
1 Like

When I replace the numbers with my shirt id it send me to the shirt

Can you send the link/id of the shirt? It should look like a template(layed flat) and not an actual shirt.

Sailboat - Roblox oops its the actual shirt

Yep, that’s the problem. There are ways to get the template id from a shirt.

Follow this to get the template version:

Put the script that it provides into the command bar at the bottom of Roblox Studio.

1 Like