Save time with this little tip

Hello everyone, I’ve been scripting for over 2 years now but just now i discovered how u can save time with this little thing.
When it comes to disabling/enabling guis or other things which requires checking state of something(true or false) and then doing something the most common approach to this would be

if gui.Enabled = true then
gui.Enabled = false else
gui.Enabled = true
end

this little block of code takes WHOOOLEEE 4 LINESS and an estimate of 30 seconds of writing so what about we save our hands a lil bit and go with something like this

gui.Enabled = not gui.Enabled

Yeah… thats it, 1 line of code and 10 seconds to write
please dont make me look stupid, commenting that this is common sense (im sure that ive seen alot of people doing it 1st method)

13 Likes

Whilst were on the topic of if statements and saving time heres another tip, see this?

if total >= minimum then
    HasEnough = True
end

Thats code, but we can shorten it!!

HasEnough = total >= minimum

Boom shortened!
What are some other cases with if statements where you can save time?

PS: Good work @SOWLMGT ! This is something most beginners wont realize but it really does save time so people knowing this is great!

11 Likes