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

How to remove clothes off a player?

Asked by
thePyxi 179
8 years ago

As the player spawns, I want to remove the majority of their clothing. It does go through the first few things but once it gets to line 27-37, it doesn't work. This is for the shirt, pants, and shirt graphic (t-shirt).

Here's the code.

01wait(1)
02    local d = script.Parent.Parent.Character:GetChildren()
03    for i=1, #d do
04        if (d[i].className == "Hat") then
05            d[i]:remove()
06        end
07    end
08 
09local humanoid = script.Parent.Parent.Character:FindFirstChild("Humanoid")
10if humanoid then
11    for i,v in pairs (script.Parent.Parent.Character:GetChildren()) do
12        if v:IsA("CharacterMesh") then
13            v:Destroy()
14        wait()
15            print(v.Name.." has been removed from "..script.Parent.Parent.Character.Name)
View all 37 lines...
0
In line 11, you could also add an if statement: If v:IsA("ShirtGraphics") then v:Destroy() end same for Pants and Shirt. I haven't tried it, that's why i'm not posting it as an answer. addictedroblox1414 166 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

I have tested this and it works. It successfully removed my hat, and shirt graphic(I only have those two on my character).

01for _, child in pairs(playerInWorkspace:GetChildren()) do
02    if child:IsA('Hat') then
03        print("removed hat")
04        child:Destroy()
05     end
06    if child:IsA('ShirtGraphic')then
07        print("removed shirt graphic")
08        child:Destroy()
09    end
10    if child:IsA('Shirt')then
11        print("removed shirt")
12        child:Destroy()
13    end
14    if child.Name == "Torso" then
15        for _, TorsoChild in pairs(child:GetChildren()) do
View all 22 lines...

I did not have any pants so i could not check if adding an IF statement inside the first for loop with the child:IsA('Pants') as the argument would work, but feel free to play around with it and comment back if it works. Also, after removing one of the items, you could change the color inside that if statement. For example, when removing a hat, it changes the head color to the color you specified. But then again, it will change the color to same color every time it loops back and removes another hat.

Ad
Log in to vote
0
Answered by 8 years ago

I don't know if this is 100% what you are looking for but this will remove all of the characters appearance including their Body Colors.

This is an example only

1game.Players.PlayerAdded:connect(function(plr)
2    plr.CharacterAppearanceLoaded:connect(function(plrModel) -- when the character loaded its appearance
3        local newPlr = game.Players:GetPlayerFromCharacter(plrModel) -- get the player
4        if newPlr then -- if the player is found
5            newPlr:ClearCharacterAppearance() -- remove CharacterAppearance
6        end
7    end)
8end)

Hope this helps

Answer this question