Comparison between db and debounce

I’ve noticed in several scripts that people either define debounce as either this

db = <boolean>

or this

debounce = <boolean>

My question is that what’s the difference between using db or debounce?
If they’re the same, then why would people use db instead of debounce and vice versa?

Nothing, quite literally. They are just variables with different names.

Because of personal choice or they are following a code structure guideline for an project they are working on.

1 Like

Both are variables which could be named as anything they’d like. But of course, naming convention is important when programming so it’s easiest to understand and read.

As to why one would put db or debounce, that’s completely up to preference. I personally switch between the two, just based on how I feel :sweat_smile:.

Some more examples of this would be how some people name Services :

DS = game:GetService("DataStoreService")
Data_Store = game:GetService("DataStoreService")
ds = game:GetService("DataStoreService")
store = game:GetService("DataStoreService")

It’s all just preference.

1 Like

Thanks for answering my question. I have another question now if you don’t mind.

What’s the difference between defining a variable as local or not. Let me use debounce as an example.

What’s the difference between this

local db = false

and this?

db = false

Sorry if this is a dumb question. I’m just overall curious :sweat_smile:

local defines the scope in which the variable can be used.

local deb = false

function aFunction()
    local deb_2 = false
    deb_3 = false
end


print(deb) -- false
print(deb_2) -- error
print(deb_3) -- false

Variables not defined as local are instead global. This helps when working with different variables, but with the same name.

deb = 2

function aFunction()
      local deb = false
      print(deb) -- false
end


function anotherFunction()
       local deb = "AString"
       print(deb) -- "AString"
end


print(deb) -- 2
1 Like