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

Help what does the blue text while not mean?

Asked by
iznr 0
5 years ago
local player = game.Players.LocalPlayer

while not player.PlayerGui do wait() end

I'm not sure what the while not means ``

0
It will run as long as player.PlayerGui dosent exist Fad99 286 — 5y

2 answers

Log in to vote
-1
Answered by 5 years ago

"While" is asking if something is true or false. As long as it's true, it'll keep doing whatever is under it. If it's false, it'll stop. The "not" just negates the condition being evaluated. Instead of running if it's true, the not makes it so it only runs when it's false. So, in your case there, as long as the playergui doesn't exist the while loop will keep running.

Ad
Log in to vote
-1
Answered by 5 years ago

while not tells the script to keep doing its given instruction(s) inside the loop until the condition associated with the not keyword no longer occurs. In your script, you're telling it to keep waiting until the player's PlayerGui exists. An alternative way to go about this is to simply use a repeat (...) until loop:

repeat wait() until player.PlayerGui

This is the same as while but it's just slightly clearer than while. You're telling the script to repeat the action given (yielding (waiting) in this example) until the player's PlayerGui exists.

The keyword not by itself negates the given condition, so that it checks for the opposite of that condition. Here is an example of that:

local number = 6
repeat
    number = number + 1
until not (number % 5) > 0

The above is a repeat loop that keeps going until the remainder of the number in modulus division is not greater than 0 (this means it'll keep going until the number is 10). As previously mentioned, not reverses (negates) the given condition so that it will check for the opposite of it. That is basically what you need to know about not.

0
Why did this get downvoted? DeceptiveCaster 3761 — 5y

Answer this question