Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Needing help with GetChildren?

Asked by
DevWork 80
10 years ago

I'v been trying to work out how to make a script which gets the children from the model then changes their color to a certain color i.e. Bright blue.

This is horrible:

local children = Workspace.Backpack:GetChildren()
for i = 1, #children do
    children.BrickColor = BrickColor.new("White")
end

2 answers

Log in to vote
3
Answered by 10 years ago

GetChildren() gets an objects children and should be used in table format.

for a,b in pairs(game.Workspace.BackPack:GetChildren()) do
    if b:IsA("BasePart") then
        b.BrickColor = BrickColor.new("White")
    end
end
Ad
Log in to vote
0
Answered by
h19rry 20
10 years ago
local children = Workspace.Backpack:GetChildren()
for i = 1, #children do
    children[i].BrickColor = BrickColor.new("Pink")
end
1
^ I'd use in pairs for this instead of a for i = loop... Just saying :# ObscureEntity 294 — 10y
1
^ Besides you didn't even check to make sure that all the children are BaseParts. Your script would break if there was a script/tool/ect. ObscureEntity 294 — 10y

Answer this question