Hey, I have zero knowledge in scripting and I am trying to enable particle emitters in two objects with the same name. I tried getdescendants, findfirstchild, etc. Nothing has worked for me, and due to reasons in other scripts, I can not simply rename one of the objects. How can I go about this? (The script I am using is EngineFunctions)
Would renaming the objects (e.g. RotorModel1 and RotorModel2) not work? After that you can just get them seperately.
I can not, as there are other scripts and modules that depend on the current names
If you absolutely cannot rename them, you could try doing :GetChildren() and checking if the name is exactly “RotorModel”. You’d probably want to make the names in the part the same too
for i, v in ipairs(Misc:GetChildren()) do -- now you can find multiple ones.
local emit = v:FindFirstChildWhichIsA("ParticleEmitter") -- find all emitters
emit.Enabled = true
local ancestor = PATH_TO_MISC_FOLDER
for _, particleEmitter in ipairs(PATH_TO_MISC_FOLDER:GetDescendants()) do
if particleEmitter:IsA("ParticleEmitter") then
local model = particleEmitter:FindFirstAncestorOfClass("Model")
if model and model.Name == "RotorModel" and model.Parent == PATH_TO_MISC_FOLDER then
particleEmitter:Emit(PARTICLES_AMOUNT)
-- or whatever technique you are using to emit particles
end
end
end