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

How to delete a t-shirt when a character spawns?

Tried this:

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
	chr.Torso.roblox:Destroy()
end)
end)

1 answer

ShirtGraphic

When you search for roblox it could be anything in general. T-shirts in roblox aren't considered 'T-shirts' instead, they are classified as ShirtGraphic. Now, how do we access the Torso and remove the ShirtGraphic? By using the pairs function, in a nutshell, a pairs function breaks a table down; grouping all the values in a single Variable.


game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		local torso = char:WaitForChild("Torso")
		for index, value in pairs(torso:GetChildren()) do
		end
	end)
end)

Continuing on, to check if one of the values is a ShirtGraphic, we'll use the IsA function.


game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		local torso = char:WaitForChild("Torso")
		for index, value in pairs(torso:GetChildren()) do
			if value:IsA("ShirtGraphic") then
				value:Destroy()
			end
		end
	end)
end)

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