01 | game.Players.PlayerAdded:connect ( function (players) |
02 | players.CharacterAdded:connect ( function (character) |
03 | --Waiting |
04 | game.ServerStorage:WaitForChild( "UniformCode" ) |
05 | local plrfile = game.ServerStorage.UniformCode:WaitForChild(players.Name) |
06 | local Codes = plrfile:WaitForChild( "Codes" ) |
07 |
08 |
09 | local Hats 1 = Codes:WaitForChild( "Hats1" ) |
10 | local Hats 2 = Codes:WaitForChild( "Hats2" ) |
11 | local Hats 3 = Codes:WaitForChild( "Hats3" ) |
12 | local Shirts = Codes:WaitForChild( "Shirts" ) |
13 | local Pants = Codes:WaitForChild( "Pants" ) |
14 | local BodyColors = Codes:WaitForChild( "BodyColors" ) |
15 | local Express = Codes:WaitForChild( "Expressions" ) |
Alright I have this script when you join the game it gives random outfit, well I'm working on a script that does so. Anyway my problem happens on line 19 when Im trying to remove all the things the player has(exp their bodycolor) can someone tell me how to remove BodyColors from the players model?
When you getchildren, you're returning a read-only table of values.
:destroy() is also not a method of a table.
You should use a for loop and index each player and destroy the bodycolors from there.
if you assign the children of character to a variable, you can do this.
local BodyColors = character:GetChildren()
1 | for i = 1 , #BodyColors do |
2 | if BodyColors [ i ] :IsA( "Body Color" ) then |
3 | BodyColors [ i ] :Destroy() |
4 | end |
5 | end |
basically anything with a lowercase letter directly after a : like :destroy is deprecated. :Destroy() itself though is deprecated too, so :Remove() would work. For your purposes, though, you can't just remove the body colors. You have to set them to something like fossil grey or something like that.