[UNSOLVED] How To Make A Textbutton Make The Player's Shirt Template Their Original Shirt

Hey, I am sorry that the post’s name is a bit difficult to understand, but I don’t know how else to phrase this.
So, I am working on a game that lets players change their shirt, but I want to add a option to revert back to the shirt they had on their actual avatar. I tried this script, but I ran into a wall and can’t think how to change it back.
Local script:

local tb = script.Parent
local player = game.Players.LocalPlayer
tb.MouseButton1Down:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer(player)
end)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local	char = player.Character
	        if char:findFirstChild("Shirt") then
			            char.Shirt.ShirtTemplate = -- get stuck here
			        else
		            local a = Instance.new("Shirt", char)
		            a.Name = "Shirt"
			            a.ShirtTemplate = -- get stuck here
			        end
	
end)

local CharacterInfo = game.Players:GetCharacterAppearanceInfoAsync(player.UserId)
local Shirt = CharacterInfo.Shirt
local ShirtTemplate = Shirt.ShirtTemplate

you can condense that into one line if you want

local ShirtTemplate = game.Players:GetCharacterAppearanceInfoAsync(player.UserId).Shirt.ShirtTemplate
--LOCAL

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
if not player:HasAppearanceLoaded() then player.CharacterAppearanceLoaded:Wait() end

task.wait()
local clothing = {}
local shirt = character:FindFirstChildOfClass("Shirt")
local pants = character:FindFirstChildOfClass("Pants")
local tShirt = character:FindFirstChildOfClass("ShirtGraphic")
if shirt then clothing.Shirt = shirt.ShirtTemplate end
if pants then clothing.Pants = pants.PantsTemplate end
if tShirt then clothing.TShirt = tShirt.Graphic end

local textButton = script.Parent

local function onButtonClicked()
	remote:FireServer(clothing)
end

textButton.MouseButton1Click:Connect(onButtonClicked)
--SERVER

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated.RemoteEvent

local function onRemoteFired(player, clothing)
	if not player.Parent then return end
	local character = player.Character
	if not character then return end
	if clothing.Shirt then character.Shirt.ShirtTemplate = clothing.Shirt end
	if clothing.Pants then character.Pants.PantsTemplate = clothing.Pants end
	if clothing.TShirt then character["Shirt Graphic"].Graphic = clothing.TShirt end
end

remote.OnServerEvent:Connect(onRemoteFired)

test.rbxl (29.7 KB)

This is working on my end, I’ve included support for pants & t-shirts too.

1 Like