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 2 years ago
Edited 2 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:

local part = script.Parent
local particles = part.ParticleEmitter

if part.Transparency ==1 then
    particles.Enabled = false
elseif part.Transparency==0 then
    particles.Enabled = true

end

1 answer

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

heres a script lol

its a normal script btw

hope this helps

--if you want to change the min trancparency before the particles turn off then change the
--  "if part.Transparency X= 0.5 then" line

part = script.Parent
particle = part.ParticleEmitter

while true do
    if part.Transparency >= 0.5 then 
    particle.Enabled = false
    end

    if part.Transparency <= 0.5 then
    particle.Enabled = true
    end

    wait(0.1)
end
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 — 2y
0
Thank you so much guys! :) DasherX 7 — 2y
Ad

Answer this question