game.Players.PlayerAdded:connect (function(players) players.CharacterAdded:connect (function(character) --Waiting game.ServerStorage:WaitForChild("UniformCode") local plrfile = game.ServerStorage.UniformCode:WaitForChild(players.Name) local Codes = plrfile:WaitForChild("Codes") local Hats1 = Codes:WaitForChild("Hats1") local Hats2 = Codes:WaitForChild("Hats2") local Hats3 = Codes:WaitForChild("Hats3") local Shirts = Codes:WaitForChild("Shirts") local Pants = Codes:WaitForChild("Pants") local BodyColors = Codes:WaitForChild("BodyColors") local Express = Codes:WaitForChild("Expressions") --Assigning if BodyColors.Value == 0 then character:GetChildren("Body Colors"):Destroy() end end) end)
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()
for i=1, #BodyColors do if BodyColors[i]:IsA("Body Color") then BodyColors[i]:Destroy() end 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.