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

onClick script not enabling Particle Emitter?

Asked by 7 years ago

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)
0
Any error or something? DaCrazyDev 444 — 7y
0
is the pointer cursor changed to a hand when you hover over it? bossay123 45 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

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!

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) Marioluigi35 7 — 7y
Ad
Log in to vote
-1
Answered by 7 years ago

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)
0
Make sure to put my answer as answered if this worked for you! :) YouSNICKER 131 — 7y
0
This necessarily isnt helpful because if he didnt want the script to be inside of the part, then it would be worthless.\ ObscureIllusion 352 — 7y
0
Oh well I didn't realise that that's a really bad reason to -1 me though! :D YouSNICKER 131 — 7y
0
Yeah, the button was a separate part and not the part with the emitter. Thanks for helping! Marioluigi35 7 — 7y
0
You're welcome MarioLuigi35, I hope you enjoy whatever you are making hey keep us updated on what you did! YouSNICKER 131 — 7y

Answer this question