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

How would I put this in simpler form?

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

You can use not 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!!

3 comments

0

Please explain how this function works? Idk what "not" means.

0

not means false or nil i believe

0

@duckyo, no, that's incorrect. https://scriptinghelpers.org/glossary/not

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

1 comment

0

Thanks!

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