IDK why anybody would need this but if you have too many services or you are too lazy just use this
setfenv(1,
setmetatable({}, {
__index = function(_, k)
local success, service = pcall(game.GetService, game, k)
return success and service or getfenv()[k]
end
})
)
Now you can reference any service by name and it will exist, like
print(ReplicatedStorage) -- ReplicatedStorage
Or RunService etc.
But don’t use this if you are like only using 1 service Lol Honestly don’t even use it at all but I thought it was cool enough so yeah
for those wondering why this is not a good idea to use, it’s because setfenv (along with getfenv) disables Luau’s optimisations which are automatically applied. Hence, your script won’t run as fast or efficiently.
Just use a Service Autocomplete plugin honestly.
Any hacky thing that happens with modifying function environment will not be typechecked and force o0 on the script (o0 means that no bytecode optimization will be applied.)