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

What if the difference of numbers and word in debounce?

Asked by 4 years ago

Like I see people writing.

Debounce = false

Debounce = true

OR

Debounce = 0

Debounce = 1

But is there a difference to it?

1 answer

Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

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)
0
Thank you. RebornedSnoop 175 — 4y
Ad

Answer this question