How to make shirt/pants stay after death

i suggested to use SetAttribute and GetAttribute for even more sorted way but the idea was skipped

1 Like

How would this approach work? Where would I put those attributes?

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player:SetAttribute("Shirt", "ID")
	Player:SetAttribute("Pant", "ID")
	Player.CharacterAppearanceLoaded:Connect(function(Character)
		Player:SetAttribute("Shirt", Character:WaitForChild("Shirt").ShirtTemplate)
		Player:SetAttribute("Pant", Character:WaitForChild("Pants").PantsTemplate)
	end)
end)

i havent tested this but heres quick code



local Players = game:GetService("Players")
local ShirtsTable = {
	["ShirtName"] = 1234567890, -- ID
	["SecondShirtName"] = 1234567890,
}
local PantsTable = {
	["PantsName"] = 1234567890, -- ID
	["SecondPantsName"] = 1234567890,
}
local function GetData(Plr)
	local Outfit = Plr:FindFirstChild("Outfit")
	if not Outfit then
		Outfit = Instance.new("StringValue")
		Outfit.Name = "Outfit"
		Outfit.Parent = Plr
	end
	local Shirt = Outfit:GetAttribute("Shirt")
	if Shirt then
		local ShirtID = ShirtsTable[Shirt]
		if ShirtID then
			--Apply the id to the player Shirt however u want
		end
	end
	local Pants = Outfit:GetAttribute("Pants")
	if Pants then
		local PantsID = PantsTable[Pants]
		if PantsID then
			--Apply the id to the player Pants however u want
		end
	end
end
Players.PlayerAdded:Connect(function(Plr)
	repeat task.wait() until Plr.Character
	GetData(Plr)
	Plr.CharacterAdded:Connect(function()
		GetData(Plr)
	end)
end)

if u wanna change the shirt stored in “Outfit” just do

local Player = --Locate the player
local NewShirtName = --The new shirtname you stored in table
local Outfit = Player:FindFirstChild("Outfit")
if Outfit then
   Outfit:SetAttribute("Shirt", NewShirtName)
end

i hope it helps

That it was not I meant and I already figured it out how can I do it, but thanks I appreciate it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.