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

Remove a shirt from a player's character?

In part of my ServerScript, I want script to destroy the Shirt inside the player's character, if they have a shirt in their character. The script is, like I said, a ServerScript found inside the player's character.

local char = script.Parent

if char:FindFirstChild("Shirt") ~= nil then
	char:FindFirstChild("Shirt"):Destroy()
end

After running the code stated above, nothing happens. Can someone please help me?

2 comments

0

No problems with the code itself that you're posted. How do you get the script into the player's character?

0

Via StarterCharacterScripts.

1 answer

✓ Accepted answer

So, you would wait until the character has loaded everything by using CharacterAppearanceLoaded.

Example of how you would do it:

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAppearanceLoaded:Connect(function(Char)
		local Shirt = Char:FindFirstChildOfClass("Shirt")
		if (Shirt) then
			Shirt:Destroy()
		end
	end)
end)

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