i made this pretty basic Framework and i need some feedback on how to improve, everything works fine but hey ill ask anyway.
also the MainServer instance the frameworks once and the MainClient instance it too
here is the explorer too

local Main = {}
function Main.Init()
--//Services\\--
Main.ReplicatedStorage = game:GetService("ReplicatedStorage")
Main.ServerStorage = game:GetService("ServerStorage")
Main.ServerScriptService = game:GetService("ServerScriptService")
Main.RunService = game:GetService("RunService")
Main.Players = game:GetService("Players")
--//Main variables\\--
Main.EventsFolder = Main.ReplicatedStorage.Events
Main.ModulesFolder = Main.ReplicatedStorage.Modules
Main.ModuleGroup = nil
if Main.RunService:IsClient() then
Main.Player = Main.Players.LocalPlayer
Main.ModuleGroup = Main.ReplicatedStorage.Modules.Client
print("Initialized Client MainFramework")
elseif Main.RunService:IsServer() then
Main.ModuleGroup = Main.ServerScriptService.MainServer
print("Initialized Server MainFramework")
end
--//Events setup\\--
Main.Events = {}
for i,EventInstance in pairs(Main.EventsFolder:GetChildren()) do
Main.Events[EventInstance.Name] = {}
Main.Events[EventInstance.Name]["Name"] = EventInstance.Name
Main.Events[EventInstance.Name]["Type"] = EventInstance.ClassName
Main.Events[EventInstance.Name]["Connected"] = false
Main.Events[EventInstance.Name]["TimesFired"] = 0
Main.Events[EventInstance.Name]["Instance"] = EventInstance
end
--//Modules setup\\--
Main.Modules = {}
for i,ModuleInstance in pairs(Main.ModuleGroup:GetDescendants()) do
if ModuleInstance:IsA("ModuleScript") then
Main.Modules[ModuleInstance.Name] = require(ModuleInstance)
end
end
for i,ModuleInstance in pairs(Main.ModulesFolder.Shared:GetDescendants()) do
if ModuleInstance:IsA("ModuleScript") and ModuleInstance.Name ~= "MainFramework" then
Main.Modules[ModuleInstance.Name] = require(ModuleInstance)
end
end
end
function Main:ConnectEvent(Name, func)
if Main.Events[Name] then
Main.Events[Name].Connected = true
--//Remote Events\\--
if Main.Events[Name].Type == "RemoteEvent" then
if Main.RunService:IsClient() then
Main.Events[Name].Instance.OnClientEvent:Connect(func)
elseif Main.RunService:IsServer() then
Main.Events[Name].Instance.OnServerEvent:Connect(func)
end
--//Remote Functions\\--
elseif Main.Events[Name].Type == "RemoteFunction" then
if Main.RunService:IsClient() then
Main.Events[Name].Instance.OnClientInvoke = func
elseif Main.RunService:IsServer() then
Main.Events[Name].Instance.OnServerInvoke = func
end
--//Bindable Events\\--
elseif Main.Events[Name].Type == "BindableEvent" then
Main.Events[Name].Instance.Event:Connect(func)
end
end
end
function Main:FireEvent(Name, ...)
if Main.Events[Name] then
Main.Events[Name].TimesFired += 1
--//Remote Events\\--
if Main.Events[Name].Type == "RemoteEvent" then
if Main.RunService:IsClient() then
Main.Events[Name].Instance:FireServer(...)
elseif Main.RunService:IsServer() then
Main.Events[Name].Instance:FireClient(...)
end
--//Remote Functions\\--
elseif Main.Events[Name].Type == "RemoteFunction" then
if Main.RunService:IsClient() then
Main.Events[Name].Instance:InvokeServer(...)
elseif Main.RunService:IsServer() then
Main.Events[Name].Instance:InvokeClient(...)
end
--//Bindable Events\\--
elseif Main.Events[Name].Type == "BindableEvent" then
Main.Events[Name].Instance:Fire(...)
end
end
end
return Main
