Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Isn't the new shirt and pants not applying to the person?

Hello! I am making a tool that If you activate It via clicking the screen with It equipped It will change your avater to a backrooms person, however while I was working on removing shirts and pants, I stumble across a problem, the problem Is that the new shirts and pants aren't applying

script:

local tool = script.Parent

tool.Activated:Connect(function()
	local char = tool.Parent:FindFirstChild("Humanoid")
	local Model = char.Parent
	local Shirt = Instance.new("Shirt")
	local Pants = Instance.new("Pants")
	
	if char.Parent:FindFirstChild("Shirt") and char.Parent:FindFirstChild("Pants") then
		char.Parent:FindFirstChild("Shirt"):Destroy()
		char.Parent:FindFirstChild("Pants"):Destroy()
	end
	
	char.WalkSpeed = 20
	char.MaxHealth = 150
	char.Health = 150
	Shirt.Parent = Model
	Shirt.ShirtTemplate = "https://web.roblox.com/catalog/8878853958/Async-Hazmat-Suit-Shirt-The-Backrooms"
	Pants.Parent = Model
	Pants.PantsTemplate = "https://web.roblox.com/catalog/9575156100/Black-Shoes-Async-Hazmat-Suit-The-Backrooms"
	tool:Destroy()
end)

1 answer

Instead of instantly creating a new instance for the clothing use:

-- If an instance already exists that instance will be used, otherwise It will create a new one
local Shirt = Model:FindFirstChildOfClass("Shirt") or Instance.new("Shirt", Model)
local Pants = Model:FindFirstChildOfClass("Pants") or Instance.new("Pants", Model)

And for the templates use:

Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=8878853958"
Pants.PantsTemplate = "http://www.roblox.com/asset/?id=9575156100"

This discussion is preserved as it was. New answers, comments, and votes are closed.