Why does Roblox not have service globals?
game:GetService(“Service”) or game.Service is probably one of the most rewritten pieces of code in scripting that slows down workflow and clogs up scripting space to declare their variables. Not only that, but scripts will usually have a different name for these like:
local run = game:GetService("RunService")
local RunService = game:GetService("RunService")
local runS = game:GetService("RunService")
local RS = game:GetService("RunService")
local rs = game:service("RunService")
This leads to inconsistency when reading code.
ModuleScripts
You could use a ModuleScript containing these services, but that prevents scripts from being stand-alone. They will need to have a reference to the module script. If they were shared or posted on a debugging forum, then these scripts would not work and people would have to waste time rewriting or adding these services to the script. Then, the original owner would have to take the edited code and replace the new service variables with their own.
service
Global
Why not add a service
global to Roblox that holds services? This would vastly improve readability in code and speed up workflow.
By having a service
global, this would further improve readability by highlighting them blue in the script editor to help users realize when a Roblox Service is in use. service
would also demotivate people from using the deprecated :service()
function for new work. Services would no longer need to be declared in every script which will free up script real estate.
The workspace
global would also become consistent with Service capitalization so people who want consistency would use service.Workspace
instead of game:GetService("Workspace")
. The inconsistency of using local Workspace = game:GetService("Workspace")
instead of workspace
has confused users before.
Lastly, having a service
global would reduce the number of people who use the bad practice of indexing services in code like game.Players
. This would reduce headaches for people that wonder why everything is broken when they change the service name and allow Roblox to freely change the name to modern standards.
for _, v in next, service.Players:GetPlayers() do
-- Code
end
-- The old workspace global is now consistent with Service Capitalization
local character = service.Workspace.Characters:FindFirstChild("Shedletsky")
service.RunService:BindToRenderStep("Render Ocean", Enum.RenderPriority.Camera.Value - 6, updateOcean)