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

How would I put this in simpler form?

Asked by 8 years ago
while true do
    game.Workspace.BrokenCeiling.Sparkle.ParticleEmitter.Enabled = false
    wait(.2)
    game.Workspace.BrokenCeiling.Sparkle.ParticleEmitter.Enabled = true
    wait(.2)
    game.Workspace.BrokenCeiling.Sparkle.ParticleEmitter.Enabled = false
end

People tell me scripting like this is frowned upon. Please tell me how to narrow this down to something more sophisticated?

2 answers

Log in to vote
2
Answered by 8 years ago

You can usenot to toggle between false and true.

while wait(0.2) do
    game.Workspace.BrokenCeiling.Sparkle.ParticleEmitter.Enabled =  not game.Workspace.BrokenCeiling.Sparkle.ParticleEmitter.Enabled--If this is false then it will be changed to true and if its true then it will be false.
end

~UserOnly16Charcters, Hoped I helped you to answer your question! If you have any further question, don't hesitate to comment below!!

0
Please explain how this function works? Idk what "not" means. james24dj 90 — 8y
0
not means false or nil i believe duckyo011 36 — 8y
0
@duckyo, no, that's incorrect. https://scriptinghelpers.org/glossary/not Perci1 4988 — 8y
Ad
Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

To expand on user's answer a bit, not reverses a boolean value.

print(not true) --> false
print(not false) --> true

Therefore in his example code, you are setting the Enabled property to whatever it doesn't currently equal - to its opposite.

To shorten that annoyingly long path, you can just put this script inside the ParticleEmitter itself, then just use script.Parent;

while wait(0.2) do
    script.Parent.Enabled = not script.Parent.Enabled
end
0
Thanks! james24dj 90 — 8y

Answer this question