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

What if the difference of numbers and word in debounce?

Like I see people writing.

Debounce = false

Debounce = true

OR

Debounce = 0

Debounce = 1

But is there a difference to it?

1 answer

✓ Accepted answer

In most other programming languages 0 is false, and any other number is true(by default people use 1); however, in lua

only true is true

and

false or nil is false.

debounce is usually a variable type called a boolean, being true or false. These values are used in expressions such as if statements.

https://roblox.fandom.com/wiki/Boolean

within this article, the second sentence explains that LUA interpreters 0 as true, so using numbers as debounce variables I believe is not correct. Since debounce is usually used to prohibit re-access to a block of code.

if you were to use numbers for debounce then you would have to do something like

if debounce ~= 0 then
	print("true")
else 
	print("false")

instead of

if debounce then
	print("true")
else
	print("false)

1 comment

0

Thank you.

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