#Why wont this Emit the particles?
1 messages · Page 1 of 1 (latest)
:GetDescendants() doesn't need any parameters and returns a table containing all descendants within the part. Use :FindFirstChild() or :WaitForChild().
Im trying to get several Particle emitters is the thing
I know its very disorganized but I need each of these in several parts with most of them on attatchments in other parts
Use LightningStrike and get the descendants, loop through the table, check if instance is a particleemitter using :IsA() then call Emit
second argument of the for loop
Im confused Sorry
do you know how to use for loop
Im Still Relatively new, If I saw a For loop I could identify it but I really dont know how to use it
** You are now Level 10! **
the code you provided have while loops, you know how to use it?
fundamentally, what does the while loop needs to run?
It needs to be True? Like it needs the "true" to be true
What about true, what are they?
recommend read every page in this article https://create.roblox.com/docs/tutorials/fundamentals/coding-1/coding-fundamentals
I have no clue
Learn the fundamentals, Pyro-Fire have given the link for you
I'll try but im kinda on a time crunch because of the Jam
Okay I think I kinda get it
so If I want it to emmit on an increment
for count 0, 1 do
wait(5)
feedbackSound:Play()
P1:Emit(EMIT_AMOUNT)
end
And that would continue looping it
because I dont have a 3rd number
or I got my two confused and it needed to be 1, 0
you don't need to make it on for loop increment
I was jsut asking if you know how to do it
Oh
Did I get this right atleast?
well yes but you're missing equal sign on the first argument
do you know tables
Not Really
tables are multi-variable container. they use index and value, which can be number or letter (string). Index as the variable name and value as, well you know
Mhm
you can use table in for loop by doing for a, b in c where c is the table argument
Okay
the for loop will iterate through that table, giving a as the index and b as the value
do you know if statement?
you dont need true or false,
well, the if statement wants to know if its true or false, but in this case, you call it a conditional
so if (a == 1), where a is 1. the conditional will return true
if a is not 1, it will return false
so
making the if statemnt will not run the code
for 1, 5 in 5
if a == 2
end
Ill get false?
If it was written correctly
the second loop will turn true
So it adds to A after every loop?
So It'll do one loop, causing A = 1 and B = 1, And Because theyre the same now It would stop
yes
Got it
if the end count is 5
a + 1, until it reaches 5
since the step is 1
if the step count is 2
a + 2 until 5
Ah
though the code will add 2 times only since you can't add 2 more than 5
for 0, 5 in 1
if a == 2
end
That'll end on the second loop
But if I switched it to a == 5 it'd end on the fifth
or is It adding two because of the a == 2
althought you have to be careful with the variable you set it to
when you set a = 0, the for loop will run another time until it reached the end count
basically making it run 3 times instead of the actual end count
Mhm
this is teh correct way
Alright
now you got the basics of the for loop
Yes
lets move to solving your emitter problem
Since your particles are within a folder, we can use :GetDescendants(), calling it from the folder object to get the descendants of objects within the folder
we can use that table and iterate it using for loop
So this?
Yes!
The amount of times the loop has run, or like the starting value
mmm in this case it doesn't
you're iteratible a table
they contain index and value
Sorry Im a bit confused
what does a table contain
Index and Value
Great, now when you put it into a for loop, what does the loop do to that table?
I feel like my guesses are wrong
Either Load everything in the table or check if all of it is there
i think you're getting confused
for loops have different use-cases
refer to this
Im really not getting it
Im confused on what the loop is doing to the table
I can see that its looping 4 times
Is it printing each object each loop?
Upper
yes
And lower is printing the current number of loop
yes
Okay
So Each loop
Would print each object once
and A is the number of loops
That makes a bit more sense
The printed number
the for loop wouldn't print the object once, look in the table, how many variables does it have?
How can I use that in the solution to my problem?
GetDescendants() returns a table containing objects, the loop will iterate that table and return value as the objects
Am I putting "ParticleEmitter" in the Get Descendants or is it not neccesarry?
unneccessary since the function doesn't need any argument
Okay
what GetDescendant basically do is, it'll use the object that called the function, store every object exists within that object into a table
Mhm
now that we have value, we use if statement to know if the object is SPECIFICALLY a ParticleEmitter object using :IsA() inside the table for loop
try writing the code
You got it right
replace that table with folder and the descedants function code
So this?
Because P1 is equal to the get Descendants function
I did and it worked, But
Where would I put the wait inside of the loop?
Inside the if?
Or before it
Okay, Can I write a "While True Do" for the sound and have it be the same wait as the for loop?
Or will it need to be all in the same thing
In the for loop
mm no
GetDescendants() returns every object within the folder, your folder could have parts, attachments, etc
Mhm
the for loop will run EVERY object it iterate
so you want it to run specificly for particleemitter
we checked the object is a particle emitter
we wwant the sound to play with the emitter
Yes
so where?
Outside of it
in the for loop or the if statement
In the loop, not in the if
That'll make the sound run every object it searched but not specificly the emitter which what you wanted
the if statement
can i see your full code
Theres the code and video showing what I mean
The video doesnt have sound
but the sound played when the effect played
its just that not all of it played
Oh you want all the particle to run every 5 second?
use while loop and place wait() below it. place the for loop code inside the while loop, remove the wait code in the for loop
This?
Yup, the while loop will act as a continous loop to call the for loop emitting the particles
That works!!
Instead of wait() do task.wait() also you can just while task.wait(5) do instead of extra true
also works
totally didn't spend 1 hour of my life teaching a newbie
And please, learn the fundamentals to fully understand programming and the functionality of Roblox Studio
✅
I will, Its my first time doing stuff on Roblox Studio in the past couple months, The last thing I worked with was Camera movements and I havent worked with particle code much
also, just so you know, immediately begining to emit after parenting to workspace won't work, you need to task.wait(0.1) before emitting or else clients won't catch up, said this because i had this annoying issue i couldn't resolve for a day