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

onClick script not enabling Particle Emitter?

I'm making a button that will enable and disable a Particle Emitter after five seconds but nothing happens once I click the button.

function onClick()
	game.Workspace.Part.ParticleEmitter.Enabled = true
	wait(5)
	game.Workspace.Part.ParticleEmitter.Enabled = false
end

script.Parent.ClickDetector:connect(onClick)

2 comments

0

Any error or something?

0

is the pointer cursor changed to a hand when you hover over it?

2 answers

✓ Accepted answer

A possibility of it not working could be simply because of a silly mistake. The silly mistake in this case would be that, because there is multiple parts in the Workspace named "Part" itll go with the first one the script finds, and attempt to find Particle Emitter, and if it doesnt than it just errors.

The best way to fix this is to rename the part, or put the script inside of the part and use script.Parent.

Hope I helped, csmz!

1 comment

0

Oh my god, thank you for telling me about that! I had actually forgot to add the "MouseClick" part in line 7's code so that ultimately fixed everything! Thank you so much (and sorry for being late haha)

I edited your code and made it work. Instead of grabbing the part from workspace just use script.Parent

function onClick()
    script.Parent.ParticleEmitter.Enabled = true
    wait(5)
	script.Parent.ParticleEmitter.Enabled = false
end

script.Parent.ClickDetector:connect(onClick)

5 comments

0

Make sure to put my answer as answered if this worked for you! :)

0

This necessarily isnt helpful because if he didnt want the script to be inside of the part, then it would be worthless.\

0

Oh well I didn't realise that that's a really bad reason to -1 me though! :D

0

Yeah, the button was a separate part and not the part with the emitter. Thanks for helping!

0

You're welcome MarioLuigi35, I hope you enjoy whatever you are making hey keep us updated on what you did!

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