hey everybody
Is there a way that I can get all children and change their properties at once?
and how would i go about doing this?
local Children = game.workspace.Model:GetChildren()
for i = 1, #Children do
Children[i].Color = Color3.fromRGB(255, 0, 0)
end
Just adding on to the previous solution on this thread, here is the API reference, just thought it could be handy for you
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 Just saying btw.
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
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.
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.