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

Help With Boolean Statement Please?

Asked by 6 years ago

Yes i might be dumb, but, can someone help me understand boolean more? im confused and dont understand how to use them right.

Yes i know you can do

var1 = true

while var1 == true do

print"hello"

end

and if its not true then while not.

but my problem is, how do i make it where if i do something the variable is false? all the tutorials i watch tell me that simple problems i did above but never put it to a real situation.

Like

var1 = true

while var1 == true do print"hello" wait(1) end

wait (10)

var1= false

while not var1 == true do print"nope" wait(1) end

I tried that but it never worked. Please help me im stupid.

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago
var1 = true

while var1 == true do print"hello" wait(1) end

wait (10)

var1= false

while not var1 == true do print"nope" wait(1) end

This script will never work, when you're running a Loop, the script stops reading!

to solve this, you have to use functions (maybe called after a event or after some time '-')

this script should work:

var1 = true
timer = 0

while var1 == true do
    print("hello")
    timer = timer + 1
    if timer == 10 then
        break
    end
    wait(1) 
end

var1= false

while not var1 == true do 
print("nope")
wait(1) 
end

Good Luck with your games

0
Thank you JuuzouBlitz 75 — 6y
Ad

Answer this question