Variable Consistency using camelCase

local money = 5
local jumpBoost = 2.5
local aRandomVariable = 5

local UserInputService = game:GetService("UserInputService")
-- service name is UserInputService is it appropriate to use userInputService or UserInputService

I’m not sure if I should use camelCase for all variables to keep everything consistent or to use the actual service name become it’s referencing the service which already has a name

also is it better to use camelCase for functions too or is it neater if it’s only variables

I know this is down to preference but I want my code to be as readable and consistent as possible (for me and others)

what do you do?

3 Likes

Honestly, my code is all over the place and its just situational for what I name things. Sometimes I use underscores when there is one object that has a lot of things I need to reference (i.e data_kills, data_deaths, data_xp), most of the time i use camelCase for just normal variables such as debounces and values that I’ve stored, and for services I just name them what they’re called in the GetService.

1 Like

It’s really down to however you want to do it and what you find the easiest, but if this helps there is this style guide. Naming is near the bottom. Roblox Lua Style guide

3 Likes

I have always used camelCase for variables and PascalCase for everything else. Obviously personal preference, but consistency is never a bad thing.

3 Likes

I use camelCase for normal variables, I use all caps lock for services and I use underscores for data related variables.

Examples:

listCode = 12
REPLICATEDSTORAGE = game:GetService("ReplicatedStorage")
player_exp = PLAYERS[playername].Experience.Value
1 Like