Normally you would call a variable like as
--// LocalScript
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
But instead it would be inside of a ModuleScript, so I wouldnt need to copy and paste the same variables each time I create a LocalScript
Is this even possible or should I scrap this idea?
Before
--// ModuleScript
local Variables = {
--// LocalPlayer
["Players"] = game:GetService("Players"),
["LocalPlayer"] = game:GetService("Players").LocalPlayer,
["Character"] = game:GetService("Players").LocalPlayer.Character,
["Humanoid"] = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid"),
["CurrentCamera"] = workspace.CurrentCamera,
["Mouse"] = game:GetService("Players").LocalPlayer:GetMouse(),
--// Services
["ContextActionService"] = game:GetService("ContextActionService"),
["UserInputService"] = game:GetService("UserInputService"),
["RunService"] = game:GetService("RunService"),
["MarketplaceService"] = game:GetService("MarketplaceService"),
["TweenService"] = game:GetService("TweenService"),
["GuiService"] = game:GetService("GuiService"),
--// Workspace
["Lighting"] = game:GetService("Lighting"),
["ReplicatedStorage"] = game:GetService("ReplicatedStorage"),
["ReplicatedFirst"] = game:GetService("ReplicatedFirst"),
["MaterialService"] = game:GetService("MaterialService"),
["StarterPack"] = game:GetService("StarterPack"),
["StarterPlayer"] = game:GetService("StarterPlayer"),
["StarterGui"] = game:GetService("StarterGui"),
["Teams"] = game:GetService("Teams"),
["SoundService"] = game:GetService("SoundService"),
["PlayerGui"] = game:GetService("Players").LocalPlayer.PlayerGui,
["ScreenGui"] = game:GetService("Players").LocalPlayer.PlayerGui.ScreenGui,
}
return Variables
After
--// ModuleScript
local Variables = {
--// LocalPlayer
["Players"] = game:GetService("Players"),
["LocalPlayer"] = Players.LocalPlayer,
["Character"] = LocalPlayer.Character,
["Humanoid"] = Character:WaitForChild("Humanoid"),
["CurrentCamera"] = workspace.CurrentCamera,
["Mouse"] = LocalPlayer:GetMouse(),
--// Services
["ContextActionService"] = game:GetService("ContextActionService"),
["UserInputService"] = game:GetService("UserInputService"),
["RunService"] = game:GetService("RunService"),
["MarketplaceService"] = game:GetService("MarketplaceService"),
["TweenService"] = game:GetService("TweenService"),
["GuiService"] = game:GetService("GuiService"),
--// Workspace
["Lighting"] = game:GetService("Lighting"),
["ReplicatedStorage"] = game:GetService("ReplicatedStorage"),
["ReplicatedFirst"] = game:GetService("ReplicatedFirst"),
["MaterialService"] = game:GetService("MaterialService"),
["StarterPack"] = game:GetService("StarterPack"),
["StarterPlayer"] = game:GetService("StarterPlayer"),
["StarterGui"] = game:GetService("StarterGui"),
["Teams"] = game:GetService("Teams"),
["SoundService"] = game:GetService("SoundService"),
["PlayerGui"] = LocalPlayer.PlayerGui,
["ScreenGui"] = PlayerGui.ScreenGui
}
return Variables