Activate multiple sprinklers at a time

Hello!

I know this is a pretty basic question but I’ve been taking a break from Roblox Lua for a while and kinda forgotten how to do it.

Basically I am making a Fire Alarm System, I have all the basics down but my goal is to get all the sprinklers to activate not just one (without having to use a ton of different variables and names)

How can I do this? Do I have to use “GetChildren”?

I have a folder with the sprinklers in them, here is an image

Basically I want to go into each sprinkler, into the emitter and activate the water and mist from it.

for _,sprinkler in pairs(Sprinklers:GetDescendants()) do
	if sprinkler:IsA('ParticleEmitter') then
		sprinkler.Enabled = true
	end
end

Instead of getting just the children of the folder, the script will go through the children and their children, and will repeat this until it finds a ParticleEmitter, in which case it will then enable the ParticleEmitter so it can begin spraying particles.

1 Like

Thanks for that, it worked! Just needed to add the “Sprinklers”

in this quote as a variable. Other than that it all worked, I appreciate it!