What would Technically be the "Correct way" to naming Variables?

I get that Title sounds stupid, I already know Variables can be named whatever:

local _SOMETHING_HERE
local FOG_COLOR

local playerList
local plr

local OmGhElPIcAnTrEaDtHiS

local xPxxAxxTxxTxxExxRxxNx
local _T_A_R_G_E_T_

local BoxOfCrayons
local Cup_Of_Noodles

local VeryLongNameForSomethingThatDoesntNecessarilyRequireIt

But what would Technically be the “Correct way” to naming Variables?

1 Like

The correct way is consistency. Beyond that it’s just whatever you feel like, but there are some conventions more common than others.

It’s common to reserve PascalCase for class names and other ‘type’ things such as enums and types.

It’s common to use camelCase for class properties and methods, but I’ve seen it done differently. Roblox for sure uses PascalCase for these.

I’ve seen people do either camelCase or snake_case for function names, generally I see it match the properties and methods conventions above.

Constants are almost always SCREAMING_AT_YOU.

After that, it’s up to you because nobody else will have API exposure to the things you write that aren’t listed above. That applies to variables. Do whatever is easiest for you, but make your variables consistent and descriptive. You can use key phrases like “table”, “num”, or “is” to help with descriptiveness. “isOn”, “players_table”, etc.

10 Likes

I dont think that one, thats a library :confused:

2 Likes

As part of your variable name, not as the name itself. Exempli gratia, “playerTable” or “colors_table”
It clues you in as to what type of variable it is and what purpose it has.

1 Like

I am stupid.

Personally, I use PascalCase for basically everything, and for private methods and function parameters I like to use camelCase. I also WILL NEVER overwrite globals because the highlight annoys me. The only time I allow myself to do this is if I write a custom global function.

1 Like

I just do it to Deprecated stuff like with Game as for some reason thats Deprecated and not game

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.