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

Why isn't this script to change the lifetime of a particle emitter working?

Asked by 7 years ago

I want to be able to press a button and the particle emitter to turn off, but it isn't working. This is what I have right now.

function onClicked(playerWhoClicked)
    script.Parent.Parent.Fire1.Flame.Lifetime.Max.Value = 0
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

If someone could tell me what I'm doing wrong or even how to make the script set the rate to 0, that would be really great.

1 answer

Log in to vote
0
Answered by 7 years ago

Hi!

Your problem is actually quite simple! You are setting incorrect value properties. The particle emitter does not let you physically set one value such as Max. You have to use a NumberRange in this instance.

A NumberRange can be generated such as NumberRange.new(1, 10)

Your code in conclusion should look like this:

function onClicked(playerWhoClicked)
    -- I'm not sure what your min value would be so I've left it as ?
    script.Parent.Parent.Fire1.Flame.Lifetime = NumberRange.new(?, 10)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

However, you could just simply disable the particle emitter with the code:

function onClicked(playerWhoClicked)
    script.Parent.Parent.Fire1.Flame.Enabled = false
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Hope this helped!

0
Thank you! This worked perfectly! JunkellaSyringe 2 — 7y
0
You're more than welcome! :D WelpNathan 307 — 7y
Ad

Answer this question