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

Help With Boolean Statement Please?

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 comment

1 answer

✓ Accepted answer
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

1 comment

0

Thank you

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