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

Trying out GetChildren and there's an output error that I can't fix? [SOLVED]

Asked by
Troidit 253 Moderation Voter
8 years ago

So, I'm trying to tell a whole bunch of objects to enable the ParticleEmitter and instead of individually calling out each object's name, I decided to use GetChildren(). My simple script is as follows..

local Cannons = script.Parent.Parent.Parent.Parent.ConfC:GetChildren()

function onClicked()
    for c = 1, #Cannons do
        Cannons[c].Con.ParticleEmitter.Enabled = true
    end
    wait(0.5)
    for c = 1, #Cannons do
        Cannons[c].Con.ParticleEmitter.Enabled = false
    end
end

script.Parent.MouseButton1Down:connect(onClicked)

My output error when I try to figure out what's going on comes out as: http://prnt.sc/b8i65e (follow the link to see the picture of my output) Here's also a picture of my explorer in-case someone spots that I did something wrong there: http://prnt.sc/b8i4st

My guess is that I'm simply forgetting to name something or that I'm using GetChildren() wrong. Can someone help solve my predicament?

1
Double check that every "Cannon" model does indeed have a thing called "Con" in it (and no typos--e.g., no spaces after the "n") BlueTaslem 18071 — 8y
0
Have an if statement prior to enabling and disabling cannon particles that will check if there is a part named Con in the cannon and that it is actually a model. Ex: if Cannons[c].ClassName == "Model" and Cannons[c]:FindFirstChild("Con") then M39a9am3R 3210 — 8y
0
I'll check Troidit 253 — 8y
0
It appears that one of the tricky blocks wasn't named Con, I'll make sure that this fixed my issue. Troidit 253 — 8y

Answer this question