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.
01 | wait( 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 |
09 | local humanoid = script.Parent.Parent.Character:FindFirstChild( "Humanoid" ) |
10 | if 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) |
I have tested this and it works. It successfully removed my hat, and shirt graphic(I only have those two on my character).
01 | for _, 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 |
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.
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
1 | game.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 ) |
8 | end ) |
Hope this helps