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

Why won't this GetChildren work?

Asked by 9 years ago

Hello! So recently I've been editing all of my tools for an upcoming model pack I am making. I decided to make a wallet functional. So basically when I activate the tool, a rupee comes out of it. (Yes this is form zelda) The rupee is a group of parts so it is a model. I am trying to change the model colour to Bright red, but it doesn't seem to do anything at all. it creates the model but does not change the colour. Also there is nothing in the output so I have no idea whats wrong

Tool.Activated:connect(function()
    SlashAnimLoaded:Play()
local assetId = 248897250
Asset = game:GetService("InsertService"):LoadAsset(assetId)
A = Asset.RG:GetChildren()
A.BrickColor = BrickColor.new("Bright Red")--This is where it doesn't do what it is supposed to.
Asset.Parent = game.Workspace
Asset.RG:MoveTo(Tool.Handle.Position)
end)

1 answer

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
9 years ago

Thats where the pairs come in handy, example:

local b=workspace:GetChildren()

for i,v in pairs(b) do
if v.className=="Part" then
print("part_")
end

NOTE: Take note that GetChildren() does not Modify any of the Children it is only used to Gather the Children.

you can read more off here: link

EDITED:

Tool.Activated:connect(function()
    SlashAnimLoaded:Play()
local assetId = 248897250
Asset = game:GetService("InsertService"):LoadAsset(assetId)
A = Asset.RG:GetChildren()
for i,v in pairs(A) do
if v.className=="Part" then
v.BrickColor = BrickColor.new("Bright Red")
Asset.Parent = game.Workspace
Asset.RG:MoveTo(Tool.Handle.Position)
end
end
end)

0
Okay.... I'm sure you know what I am supposed to do here, But I have absolutly no Idea how I am supposed to put my script into this. minikitkat 687 — 9y
0
Ok...I'll edit it. woodengop 1134 — 9y
0
GetChildren is only a list -- and a list doesn't have a brick color. You therefore need to edit everything IN the list, as you have. (Just clarifying) Perci1 4988 — 9y
0
Okay, Now there is a problem: It changes the Colour to grey. Not red. And in the output it says Brickcolor is not a valid member of Script. minikitkat 687 — 9y
View all comments (2 more)
0
Oh I forgot. woodengop 1134 — 9y
0
Aha!! This works! I'll have to keep this method in mind! Thanks! minikitkat 687 — 9y
Ad

Answer this question