Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Need Particle Emitter to only be ENABLED when its parent ISN'T Transparent?

Asked by 3 years ago
Edited 3 years ago

I've been trying to write a code which turns on/off the particle emitter depending on its parents transparency.

I want it so that if the parents transparency ==1 then the particle emitter is disabled, and the opposite if the parents transparency is ==0.

I am not too experienced in scripting lua and I just cannot figure this out. I also tried putting it in a while true do but that also doesn't work. Can anyone propose a fix/ something different?

Thank you for reading :)

This is what I have come up with:

1local part = script.Parent
2local particles = part.ParticleEmitter
3 
4if part.Transparency ==1 then
5    particles.Enabled = false
6elseif part.Transparency==0 then
7    particles.Enabled = true
8 
9end

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

heres a script lol

its a normal script btw

hope this helps

01--if you want to change the min trancparency before the particles turn off then change the
02--  "if part.Transparency X= 0.5 then" line
03 
04part = script.Parent
05particle = part.ParticleEmitter
06 
07while true do
08    if part.Transparency >= 0.5 then
09    particle.Enabled = false
10    end
11 
12    if part.Transparency <= 0.5 then
13    particle.Enabled = true
14    end
15 
16    wait(0.1)
17end
0
You should avoid using wait() instead you can; part:GetPropertyChangedSignal("Transparency"):Connect(function(); then you can put your if statements inside the function MarkedTomato 810 — 3y
0
Thank you so much guys! :) DasherX 7 — 3y
Ad

Answer this question