Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remove a shirt from a player's character?

Asked by
ExcelUp 24
5 years ago

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?

0
No problems with the code itself that you're posted. How do you get the script into the player's character? LukeSmasher 619 — 5y
0
Via StarterCharacterScripts. ExcelUp 24 — 5y

1 answer

Log in to vote
0
Answered by
angeI1001 123
5 years ago

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)
Ad

Answer this question