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.

wait(1)
    local d = script.Parent.Parent.Character:GetChildren() 
    for i=1, #d do 
        if (d[i].className == "Hat") then 
            d[i]:remove() 
        end 
    end

local humanoid = script.Parent.Parent.Character:FindFirstChild("Humanoid")
if humanoid then
    for i,v in pairs (script.Parent.Parent.Character:GetChildren()) do
        if v:IsA("CharacterMesh") then
            v:Destroy()
        wait()
            print(v.Name.." has been removed from "..script.Parent.Parent.Character.Name)
        end 
    end
end

script.Parent.Parent.Character.Head.BrickColor = BrickColor.new("Light orange")
script.Parent.Parent.Character.Torso.BrickColor = BrickColor.new("Institutional white")
script.Parent.Parent.Character["Left Arm"].BrickColor = BrickColor.new("Light orange")
script.Parent.Parent.Character["Right Arm"].BrickColor = BrickColor.new("Light orange")
script.Parent.Parent.Character["Left Leg"].BrickColor = BrickColor.new("Dark stone grey")
script.Parent.Parent.Character["Right Leg"].BrickColor = BrickColor.new("Dark stone grey")

function kill(nam, parent) if parent:FindFirstChild(nam) then
    parent[nam]:Destroy()
end end

game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function()
    local Character=script.Parent.Parent
    kill("roblox", Character.Torso)
    kill("Shirt", Character)
    kill("Pants", Character)
    end)
    end)
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).

for _, child in pairs(playerInWorkspace:GetChildren()) do
    if child:IsA('Hat') then
        print("removed hat")
        child:Destroy()
     end
    if child:IsA('ShirtGraphic')then
        print("removed shirt graphic")
        child:Destroy()
    end
    if child:IsA('Shirt')then
        print("removed shirt")
        child:Destroy()
    end
    if child.Name == "Torso" then
        for _, TorsoChild in pairs(child:GetChildren()) do
            if TorsoChild:IsA('Decal')then
                print("Decal Removed")
                TorsoChild:Destroy()
            end
        end
    end
end 

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

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

Hope this helps

Answer this question