#How to select all children in local script

9 messages · Page 1 of 1 (latest)

granite vault
#

I'm fairly new to coding and are making a local script to randomize the races you are when joining the game, but i didn't know how to select the children inside the model and change the skintone of the custom starter character made for the races, so I went off some things i thought would work

It simply doesn't work, nothing comes in output

extra info, i put it down to 1,2 instead of 1,11 so i can see if one of the races work before going onto coding the rest

lime crescent
#

Instance:GetChildren gives u a table.
so if you want to change every item inside that table you can use a for i loop.

local Children = Model:GetChildren()
for i,v in pairs(Children) do
  print(v:GetFullName()) --will print the whole path of the children.
  if v:IsA("BasePart") then --checks if its a basepart
    --change the color of the basepart here?
  end
end

another thing i wanted to mention;
you can get the Player's Character using the Player.CharacterAdded event.

game.Players.PlayerAdded:Connect(function(plr) --fires the event when the player is added.
  plr.CharacterAdded:Connect(function(char) --fires the event when the player's character is added.
    print("character added.")
  end)
end)

you can reference the player's character using the first paramater of Player.CharacterAdded

https://create.roblox.com/docs/reference/engine/classes/Player#CharacterAdded

Learn with documentation and resources for all creators.

surreal nexus
#

for _,v in pairs(Character:GetChildren()) do

    if v:IsA("Part") then 

        v.Color = Color3.fromRGB(NUMBER,NUMBER,NUMBER)

    end

end

#

Greatest Explained better, just ignore what i send

granite vault
#

thanks

#

by the way i had a question

#

does the script being a local script do anything with printing because nothing would print when i did a local

lime crescent
granite vault
#

oh ok thank you