#Why wont this Emit the particles?

1 messages · Page 1 of 1 (latest)

lucid sapphire
brisk fulcrum
#

:GetDescendants() doesn't need any parameters and returns a table containing all descendants within the part. Use :FindFirstChild() or :WaitForChild().

lucid sapphire
#

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

brisk fulcrum
#

Use LightningStrike and get the descendants, loop through the table, check if instance is a particleemitter using :IsA() then call Emit

lucid sapphire
#

How would I do that

#

Or where does the :IsA go?

brisk fulcrum
#

second argument of the for loop

lucid sapphire
#

Im confused Sorry

brisk fulcrum
#

do you know how to use for loop

lucid sapphire
#

Kinda

#

Not enough

brisk fulcrum
#

how about you show me how you use for loop

#

start by number increment

lucid sapphire
#

Im Still Relatively new, If I saw a For loop I could identify it but I really dont know how to use it

cunning oarBOT
#

studio** You are now Level 10! **studio

brisk fulcrum
lucid sapphire
#

while true do

#

I know that loops

brisk fulcrum
#

fundamentally, what does the while loop needs to run?

lucid sapphire
#

It needs to be True? Like it needs the "true" to be true

forest badger
brisk fulcrum
forest badger
lucid sapphire
brisk fulcrum
lucid sapphire
#

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

brisk fulcrum
#

you don't need to make it on for loop increment

#

I was jsut asking if you know how to do it

lucid sapphire
#

Oh

lucid sapphire
brisk fulcrum
#

well yes but you're missing equal sign on the first argument

lucid sapphire
#

Right yeah

#

Okay

#

How Will that help with my original issue

brisk fulcrum
#

do you know tables

lucid sapphire
#

Not Really

brisk fulcrum
#

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

lucid sapphire
#

Mhm

brisk fulcrum
#

you can use table in for loop by doing for a, b in c where c is the table argument

lucid sapphire
#

Okay

brisk fulcrum
#

the for loop will iterate through that table, giving a as the index and b as the value

#

do you know if statement?

lucid sapphire
#

if ( ) true do?

#

Or false

brisk fulcrum
#

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

lucid sapphire
#

so

brisk fulcrum
#

making the if statemnt will not run the code

lucid sapphire
#

for 1, 5 in 5
if a == 2
end

Ill get false?

brisk fulcrum
#

yes

#

well not in that case

lucid sapphire
#

If it was written correctly

brisk fulcrum
#

the second loop will turn true

lucid sapphire
#

So it adds to A after every loop?

brisk fulcrum
#

let me recall

#

for A = 0 (variable), B = 1 (this is end count), C = 1 (Steps) do

lucid sapphire
#

So It'll do one loop, causing A = 1 and B = 1, And Because theyre the same now It would stop

brisk fulcrum
#

yes

lucid sapphire
#

Got it

brisk fulcrum
#

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

lucid sapphire
#

Ah

brisk fulcrum
#

though the code will add 2 times only since you can't add 2 more than 5

lucid sapphire
#

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

brisk fulcrum
#

no

#

c

#

c is step value

lucid sapphire
#

got it

#

So It would end on the fifth loop for a == 5

#

That makes sense

brisk fulcrum
#

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

lucid sapphire
#

Mhm

brisk fulcrum
#

this is teh correct way

lucid sapphire
#

Alright

brisk fulcrum
#

now you got the basics of the for loop

lucid sapphire
#

Yes

brisk fulcrum
#

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

brisk fulcrum
#

Yes!

lucid sapphire
#

Okay

#

Where would the For loop go then?

brisk fulcrum
#

what does A variable give us

#

when you iterate through table

lucid sapphire
#

The amount of times the loop has run, or like the starting value

brisk fulcrum
#

well thats a different case

#

i mean

#

ok that is

#

what does B give us

lucid sapphire
#

The end goal

#

The amount of times we want it to run, or the end value

brisk fulcrum
#

mmm in this case it doesn't

#

you're iteratible a table

#

they contain index and value

lucid sapphire
#

Mhm

#

So what would B be in this instance?

brisk fulcrum
#

im sure you know

#

i jsut told you

lucid sapphire
#

Sorry Im a bit confused

brisk fulcrum
#

what does a table contain

lucid sapphire
#

Index and Value

brisk fulcrum
#

Great, now when you put it into a for loop, what does the loop do to that table?

lucid sapphire
#

I feel like my guesses are wrong

#

Either Load everything in the table or check if all of it is there

brisk fulcrum
#

i think you're getting confused

#

for loops have different use-cases

#

refer to this

lucid sapphire
#

Im really not getting it

brisk fulcrum
#

ask me

#

what is it that you're not getting

lucid sapphire
#

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?

brisk fulcrum
#

which for loop

#

lower or the upper

lucid sapphire
#

Upper

brisk fulcrum
#

yes

lucid sapphire
#

And lower is printing the current number of loop

brisk fulcrum
#

yes

lucid sapphire
#

Okay

#

So Each loop

#

Would print each object once

#

and A is the number of loops

#

That makes a bit more sense

lucid sapphire
brisk fulcrum
lucid sapphire
#

It has two

#

So would it print both objects per loop?

brisk fulcrum
#

Yea

#

Its basically the same as the lower for loop

#

but used in table

lucid sapphire
#

How can I use that in the solution to my problem?

brisk fulcrum
lucid sapphire
#

Am I putting "ParticleEmitter" in the Get Descendants or is it not neccesarry?

brisk fulcrum
#

unneccessary since the function doesn't need any argument

lucid sapphire
#

Okay

brisk fulcrum
#

what GetDescendant basically do is, it'll use the object that called the function, store every object exists within that object into a table

lucid sapphire
#

Mhm

brisk fulcrum
#

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

lucid sapphire
#

I thought this

#

But the table is saying wrong

brisk fulcrum
#

replace that table with folder and the descedants function code

lucid sapphire
#

So this?

brisk fulcrum
#

nnno

#

oh wait

lucid sapphire
#

Because P1 is equal to the get Descendants function

brisk fulcrum
#

yes it is correct

#

try running the code

lucid sapphire
#

I did and it worked, But

#

Where would I put the wait inside of the loop?

#

Inside the if?

#

Or before it

brisk fulcrum
#

before it

#

basically anywhere specificly

#

just not in the statement code blocks

lucid sapphire
#

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

brisk fulcrum
#

no

#

you want it to play with the effect, so where do you put it?

lucid sapphire
#

In the for loop

brisk fulcrum
#

mm no

#

GetDescendants() returns every object within the folder, your folder could have parts, attachments, etc

lucid sapphire
#

Mhm

brisk fulcrum
#

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

lucid sapphire
#

Yes

brisk fulcrum
#

so where?

lucid sapphire
#

Outside of it

brisk fulcrum
#

in the for loop or the if statement

lucid sapphire
#

In the loop, not in the if

brisk fulcrum
#

That'll make the sound run every object it searched but not specificly the emitter which what you wanted

lucid sapphire
#

Mhm

#

So where would it go?

brisk fulcrum
#

the if statement

lucid sapphire
#

It

#

kinda worked

#

Its not using every emitter

brisk fulcrum
lucid sapphire
#

The video doesnt have sound

#

but the sound played when the effect played

#

its just that not all of it played

brisk fulcrum
lucid sapphire
#

Yes

#

The full effect

brisk fulcrum
#

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

lucid sapphire
brisk fulcrum
#

Yup, the while loop will act as a continous loop to call the for loop emitting the particles

lucid sapphire
#

That works!!

reef pond
#

Instead of wait() do task.wait() also you can just while task.wait(5) do instead of extra true

brisk fulcrum
#

also works

lucid sapphire
#

Thank you!!!!!!

#

And thanks for the small lesson :)

brisk fulcrum
#

totally didn't spend 1 hour of my life teaching a newbie

reef pond
#

A hour!?!?

#

dang

#

the dedication 💪

brisk fulcrum
reef pond
#

lucid sapphire
#

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

reef pond
#

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