Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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!

2 comments

0

Thank you! This worked perfectly!

0

You're more than welcome! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.