How can I fix this shirt cloning problem?

Hi, I’m trying to make a load previous shirt script from character viewport. So basically if you die the character viewport will give you the previous shirt you were wearing.

This is the script that I’m working on:

local Player = game.Players.LocalPlayer
local Char = Player.Character
local Shirt = Player.PlayerGui.UniformGUI.Frame.ViewportFrame.ViewportCharacter.Character.Shirt

Char:WaitForChild("Humanoid").Died:Connect(function()
	Shirt:Clone()
	wait(8)
	game.Workspace[Player.Name].Shirt:Destroy()
	wait(1)
	Shirt.Parent = game.Workspace[Player.Name]
end)

I still have no clue why this won’t work but any helps will be appreciated, Thanks.

Shirt:Clone() returns a new Instance, but you have not used this value:

local shirtClone = Shirt:Clone()

In your code, Shirt will still be the same Shirt, so when you Destroy() it you will not be able to get it back or clone it later.

I tried that but after the player died and spawned back the script stopped working