Hello I was wondering if it’s a good idea to create a module script for requiring services and other module scripts like this
--module script
local services = {}
services.Players = game:GetService("Players")
services.ReplicatedStorage = game:GetService("ReplicatedStorage")
services.TweenService = game:GetService("TweenService")
services.UserInputService = game:GetService("UserInputService")
services.ServerStorage = game:GetService("ServerStorage")
services.RunService = game:GetService("RunService")
--requiring my modules
services.Utils = require(services.ReplicatedStorage.Scripts.Utils)
services.Config = require(services.ReplicatedStorage.Scripts.Config)
return services
--server script or local script
local Services = require(game:GetService("ReplicatedStorage").Scripts.Services)
Services.Players.PlayerAdded:Connect(function(player)
...
end)
Services.RunService.Heartbeat:Connect(function(dt)
...
end)
Or is it better to just require all the services in each script in which i need them?
Thank you!