How do i get all children

hey everybody :smiley:
Is there a way that I can get all children and change their properties at once?
and how would i go about doing this?

2 Likes
local Children = game.workspace.Model:GetChildren()

for i = 1, #Children do
   Children[i].Color = Color3.fromRGB(255, 0, 0)
end
1 Like

Just adding on to the previous solution on this thread, here is the API reference, just thought it could be handy for you
https://developer.roblox.com/en-us/api-reference/function/Instance/GetChildren

2 Likes

to get children you do

stuff=thing:GetChildren()

to do stuff with them you do this

for i = 1, #stuff do
   stuff[i]---
end

you must use

  stuff[i]

so script will know with what to work

Actually instead of naming it as thing you can name it as Instance :slight_smile: Just saying btw.

1 Like

yeah ik but it doesnt seem to work since im enabling beams from a script but it is inside a charactermodel do scripts run in charactermodels?

Scripts do run as long as they are a descendant of workspace too, so I don’t really know why its not working unless I can see the code.

local Children = script.Parent.ReentryFlames:GetChildren()

for i = 1, #Children do

Children[i].Enabled = true

end

Are you sure the property Enabled isn’t changing?

Also try using this loop, if its not working still.

local Children = script.Parent.ReentryFlames:GetChildren()

for i,v in pairs(Children) do
   v.Enabled = true
end

its not working however the origins of the script is in the startercharacter in starterplayer could that be why?

Oh. Yeah, I would recommend it removing from there, as they only work if they are a descendant of ServerScriptService or Workspace.

You could place it in the model too, if it meets your requirements?

place it in what model. however it already is in the startercharacter

Check where it is. If it isn’t workspace and it’s a workspace-type entity then it wont work or show up. I’m pretty sure a “beam” instance needs to be in workspace for it to work.

Likewise what @WaterJamesPlough said, Check the value. Is it active when you set it to active. Is it not when you set it to not?

What are the “children” can you show us an image or some sort of visualisation of the explorer. And the children the script is trying to access

1 Like

Do you want to get the children of children as well? If so do this:

All Decendants Script
for _, v in ipairs (script.Parent.ReentryFlames:GetDecendants()) do 
   if (v:IsA("Beam"))  then
       v.Enabled = true
  end
end

The ones above arent working because there trying to set all children, not just beams.

You can’t call an instance as a function. This will error.

1 Like

Actually, why did you edit the post? It was fine when it was :GetDescendants method on the instance itself.

Oops. I deleted more than I meant to lol. Sorry! I’ll fix it.