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?

4 comments

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")

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

0

I'll check

0

It appears that one of the tricky blocks wasn't named Con, I'll make sure that this fixed my issue.