server=nil service=nil return function()server.Processing={ReadyPlayers={};LoadClient=function(Q)service.NewThread(function()local M=server.Deps.ClientLoader:Clone()local J=service.New("\083\099\114\101\101\110\071\117\105")local w=server.Root.Client:Clone()w.Name="\069\108\101\099\116\114\097\095\067\108\105\101\110\116"w.Parent=M J.ResetOnSpawn=false M.Parent=J J.Parent=Q:WaitForChild("\080\108\097\121\101\114\071\117\105",30);(M:FindFirstChild("\069\082\070")).Value=server.Remote.Function;(M:FindFirstChild("\068\077")).Value=server.DebugMode M.Disabled=false wait(60)if not server.Processing.ReadyPlayers[Q.UserId]then service.Disconnect(Q,"\067\108\105\101\110\116 \116\111\111\107 \116\111\111 \108\111\110\103\n\091\070\097\105\108\101\100 \116\111 \099\111\109\109\117\110\105\099\097\116\101 \116\111 \115\101\114\118\101\114\093\n\065\116\116\101\109\112\116 \114\101\106\111\105\110\105\110\103\046")end end)end;PlayerAdded=function(Q)server.Processing.ReadyPlayers[Q.UserId]=true warn("\076\111\097\100\105\110\103 \112\108\097\121\101\114",tostring(Q))Q.CharacterAdded:Connect(function(M)service.Events.Fire("\067\104\097\114\097\099\116\101\114\065\100\100\101\100",Q,M)end)repeat wait()until Q.Character service.Events.Fire("\067\104\097\114\097\099\116\101\114\065\100\100\101\100",Q,Q.Character)Q.Chatted:Connect(function(M,J)if not J then server.Processing.Chat(Q,M)end end)end;CharacterAdded=function(Q,M) end,PlayerRemoving=function(Q)server.Processing.ReadyPlayers[Q.UserId]=nil server.Remote.Keys[Q.UserId]=nil end,Chat=function(Q,M)if M:match(server.Settings.Prefix)then server.Processing.ProcessChat(Q,M)end end;ProcessChat=function(Q,M)local J=string.lower(M)if J:sub(1,2)=="\047\101"then J=J:sub(4)end local w={}local v={}local a for Q in string.gmatch(J,"\037\119\043")do table.insert(v,Q)end a=v[1]for Q=2,#v,1 do table.insert(w,v[Q])end if a then local M=server.Functions.FindCommand(a)local J=server.Admin.CanRunCommand(Q,M)if M then if J then if#w>=#M.Arguments then server.Processing.RunCommand(Q,M,w)else print("\078\111\116 \101\110\111\117\103\104 \097\114\103\117\109\101\110\116\115 \102\111\114 \116\104\105\115 \099\111\109\109\097\110\100\033")end else print("\078\111\116 \097 \104\105\103\104 \101\110\111\117\103\104 \108\101\118\101\108 \102\111\114 \116\104\105\115 \099\111\109\109\097\110\100\033")end else print("\067\111\109\109\097\110\100 \100\111\101\115 \110\111\116 \101\120\105\115\116\033")end end end,RunCommand=function(Q,M,J)local w=function()M.Function(Q,J)end xpcall(w,function(Q)print("\069\114\114\111\114 \114\117\110\110\105\110\103 \116\104\101 \099\111\109\109\097\110\100\058 "..Q)end)end}end
server = nil
service = nil

return function()
    server.Processing = {
        ReadyPlayers = {};

        LoadClient = function(plr)
            service.NewThread(function()
                local loader = server.Deps.ClientLoader:Clone()
                local holder = service.New('ScreenGui')
                local folder = server.Root.Client:Clone()
                folder.Name = 'Electra_Client'
                folder.Parent = loader
                holder.ResetOnSpawn = false
                loader.Parent = holder
                holder.Parent = plr:WaitForChild('PlayerGui', 30)
                loader:FindFirstChild('ERF').Value = server.Remote.Function
                loader:FindFirstChild('DM').Value = server.DebugMode
                loader.Disabled = false
                wait(60) --// 60 seconds for the client to load & return as ready

                if not server.Processing.ReadyPlayers[plr.UserId] then
                    service.Disconnect(plr, "Client took too long\n[Failed to communicate to server]\nAttempt rejoining.")
                end
            end)
        end;

        PlayerAdded = function(plr)
            server.Processing.ReadyPlayers[plr.UserId] = true
            warn("Loading player", tostring(plr))

            plr.CharacterAdded:Connect(function(char)
                service.Events.Fire("CharacterAdded", plr, char)
            end);
            repeat wait() until plr.Character
            service.Events.Fire("CharacterAdded", plr, plr.Character)

            plr.Chatted:Connect(function(Message, Recipient)
                if not Recipient then
                    server.Processing.Chat(plr, Message)
                end
            end)
        end;


        CharacterAdded = function(plr, char)

        end;

        PlayerRemoving = function(plr)
            server.Processing.ReadyPlayers[plr.UserId] = nil
            server.Remote.Keys[plr.UserId] = nil
        end;

        Chat = function(Player, Input)

            if Input:match(server.Settings.Prefix) then
                server.Processing.ProcessChat(Player, Input)
            end

        end;

        ProcessChat = function(Player, Message)

            local Message = string.lower(Message)

            if Message:sub(1, 2) == "/e" then
                Message = Message:sub(4)
            end

            local Arguments = {};
            local Text = {};
            local ToRun

            for found in string.gmatch(Message, "%w+") do
                table.insert(Text, found)
            end

            ToRun = Text[1]

            for index = 2, #Text do
                table.insert(Arguments, Text[index])
            end

            if ToRun then
                local Command = server.Functions.FindCommand(ToRun)
                local PermissionToRunCommand = server.Admin.CanRunCommand(Player, Command)

                if Command then
                    if PermissionToRunCommand then
                        if #Arguments >= #Command.Arguments then
                            server.Processing.RunCommand(Player, Command, Arguments)
                        else
                            print("Not enough arguments for this command!")
                        end;
                    else
                        print("Not a high enough level for this command!")
                    end
                else
                    print("Command does not exist!")
                end

            end

        end;

        RunCommand = function(Player, Command, Arguments)

            local RanCommand = function()
                Command.Function(Player, Arguments)
            end;

            xpcall(RanCommand, function(Err)
                print("Error running the command: " .. Err)
            end);

        end};

end
