Trying to emit multiple particles at once

nevermind that, does firstHit and finalHit parts have particles?

they do, the particles are inside some attachments

also, in the first hit my original code isnt a problem because there arent that many particles, but for the finalHit there are a lot so it ruins the effect

but have you tried enabling them outside the script? do the particles even work?

yes, i’ve tried enabling them in and out of the script (they do work) i also searched to see if there was a way to detect if a particle was emitted but not really sure how that would help

Then that’s why my loop doesn’t work. Because index is bigger than found.
You could try just brute-forcing it and moving the first if statement from my method to second if statement, like this. Please excuse any mispells, I write this without autocomplete right in this devforum, I assume you’re smart enough to correct any.

local found = 0
for i,child in finalHit:GetDescendants() do
    found +=1
    

   if found == i then
        if child:IsA("ParticleEmitter") then
        child:Emit()
    end
   end
end

you wrote everything right, i dont see any mispells but it still doesnt show the particles, also, i made sure that the part IS in the right position AND in the workspance

Could you show us a screenshot of finalHit’s hierarchy?

image
the name isnt the problem so dont worry about that

Oh my god. How long does that Attachment chain go for? Could you show us the entire hierarchy of one attachment?

image
umm… here you go

i said that it had A LOT more particles i think

why don’t you remove the task.wait()?

wouldn’t that then emit all of the particles?

oh i think i know what you’re trying to do.

you can put a task.spawn()

task.spawn(function()
       for i,v in attachment:GetDescendants()
              task.wait()
               v:Emit(v.Rate)
       end
end)

ill try this tomorrow as its getting pretty late

I would try doing this instead:
While @StylishEyepatch was correct to use task.spawn, that would only spawn the loop, and it will still have the task.wait in-between.

for _, child in finalHit:GetDescendants() do
    task.spawn(function()
       if child:IsA('ParticleEmitter') then
          child:Emit(child:GetAttribute('EmitCount')
       end
    end)
end

thx for that, i found the solution

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.