return function(B,I)local f=I(nil,{script=script})setfenv(1,f)local Z,c,v,M,N,q,k,p,K,T,D,a,e,L,P,l,z,C,O,y,Y,t,o,X,w,u,F,b,S,h,J,W,H,G,s,g,j,i,r,A,Q,n,d,E,U,V,m,R,x,B3,I3,f3,Z3,c3,v3,M3,N3,q3,k3=_G,game,script,getfenv,setfenv,workspace,getmetatable,setmetatable,loadstring,coroutine,rawequal,typeof,print,math,warn,error,pcall,xpcall,select,rawset,rawget,ipairs,pairs,next,Rect,Axes,os,time,Faces,unpack,string,Color3,newproxy,tostring,tonumber,Instance,TweenInfo,BrickColor,NumberRange,ColorSequence,NumberSequence,ColorSequenceKeypoint,NumberSequenceKeypoint,PhysicalProperties,Region3int16,Vector3int16,require,table,type,wait,Enum,UDim,UDim2,Vector2,Vector3,Region3,CFrame,Ray,delay local p3=v local K3=B.Service local T3=B.Client local D3,a3,e3,L3,P3,l3,z3 local function C3()l3=T3.UI D3=T3.Anti a3=T3.Core z3=T3.Variables e3=T3.Functions L3=T3.Process P3=T3.Remote a3.Name="\000"a3.Special=T3.DepsName a3.MakeGui=l3.Make a3.GetGui=l3.Get a3.RemoveGui=l3.Remove a3.Init=nil end local function O3(B)a3.GetEvent()a3.RunAfterPlugins=nil end local function y3()if K3.NetworkClient then K3.TrackTask("\084\104\114\101\097\100\058 \065\080\073 \077\097\110\097\103\101\114",a3.StartAPI)end a3.RunLast=nil end;(M()).client=nil;(M()).service=nil;(M()).script=nil T3.Core={Init=C3,RunLast=y3;RunAfterPlugins=O3;Name=p3.Name;Special=p3.Name,ScriptCache={},GetEvent=function()if a3.RemoteEvent then log("\068\105\115\099\111\110\110\101\099\116 \111\108\100 \082\101\109\111\116\101\069\118\101\110\116")for B,I in X,a3.RemoteEvent.Events do I:Disconnect()end a3.RemoteEvent=nil end log("\071\101\116\116\105\110\103 \082\101\109\111\116\101\069\118\101\110\116")local B={}local I=K3.ReplicatedStorage local f=I:WaitForChild(T3.RemoteName,300)if not f then D3.Detected("\075\105\099\107","\082\101\109\111\116\101\069\118\101\110\116 \078\111\116 \070\111\117\110\100")else log("\071\101\116\116\105\110\103 \082\101\109\111\116\101\070\117\110\099\116\105\111\110")local Z=f:WaitForChild("\095\095\070\085\078\067\084\073\079\078",120)if not Z then D3.Detected("\075\105\099\107","\082\101\109\111\116\101\070\117\110\099\116\105\111\110 \078\111\116 \070\111\117\110\100")else local c={}Z.OnClientInvoke=L3.Remote B.Object=f B.Function=Z B.FireServer=f.FireServer B.Events=c c.ProcessRemote=f.OnClientEvent:Connect(L3.Remote)c.ParentChildRemoved=I.ChildRemoved:Connect(function(I)if a3.RemoteEvent==B and(I==f and B3())then P("\058\058\065\068\079\078\073\083\058\058 \082\069\077\079\084\069 \069\086\069\078\084 \082\069\077\079\086\069\068\063 \082\069-\071\082\065\066\066\073\078\071")log("~\033 \082\069\077\079\084\069\069\086\069\078\084 \087\065\083 \082\069\077\079\086\069\068\063")a3.GetEvent()end end)a3.RemoteEvent=B if not a3.Key then log("~\033 \071\101\116\116\105\110\103 \107\101\121 \102\114\111\109 \115\101\114\118\101\114")P3.Fire(T3.DepsName.."\071\069\084\095\075\069\089")end end end end,LoadPlugin=function(B)local f=m(B)local Z=N(f,I(M(f)))cPcall(Z)end,LoadBytecode=function(B,I)return(m(T3.Shared.FiOne))(B,I)end;LoadCode=function(B,I)return a3.LoadBytecode(B,I)end,StartAPI=function()local B=a3.ScriptCache local I=T3.Shared.FiOne local f=P3.Get local c=P3.GetFire local v=T3.G_API local q=T3.Allowed_API_Calls local K=K3.NewProxy local T=K3.MetaFunc local D=K3.ReadOnly local a=K3.StartLoop local L=K3.ReadOnly local z=K3.UnWrap local C=nil local O=nil local t=Z local w=p local u=x local F=e local b=l local S=o local h=P local J=X local W=R local H=y local s=Y local g=M local j=N local i=m local r=G local A=O local Q=Routine local n=cPcall local d={}j(1,w({},{__metatable=k(g())}))local E={API_Specific={Test=function()F("\087\101 \114\097\110 \116\104\101 \097\112\105 \115\112\101\099\105\102\105\099 \115\116\117\102\102")end};Service=C}local U={Access=L({},nil,nil,true),Scripts=L({ExecutePermission=function(Z,c)local v for B,I in J,B do if z(I.Script)==Z then v=I end end if v and(v.noCache~=true and(not v.runLimit or v.runLimit and v.Executions<=v.runLimit))then v.Executions=v.Executions+1 return v.Source,v.Loadstring end local M=f("\069\120\101\099\117\116\101\080\101\114\109\105\115\115\105\111\110",Z,c,true)if M and M.Source then local f if not v then f=i(I:Clone())W.insert(B,{Script=Z;Source=M.Source,Loadstring=f,noCache=M.noCache;runLimit=M.runLimit;Executions=M.Executions})else f=v.Loadstring v.Source=M.Source end return M.Source,f end end},nil,nil,true)}local V=K({__index=function(B,I)if I=="\083\099\114\105\112\116\115"then return U.Scripts elseif v and q.Client==true then if u(U[I])=="\102\117\110\099\116\105\111\110"then return T(U[I])else return U[I]end else b("\095\071 \065\080\073 \105\115 \100\105\115\097\098\108\101\100")end end,__newindex=function()b("\082\101\097\100-\111\110\108\121")end,__metatable="\065\080\073"})if not s(t,"\065\100\111\110\105\115")then if W.isfrozen and not W.isfrozen(t)or not W.isfrozen then H(t,"\065\100\111\110\105\115",V)a("\065\080\073\067\104\101\099\107",1,function()if s(t,"\065\100\111\110\105\115")~=V then if W.isfrozen and not W.isfrozen(t)or not W.isfrozen then H(t,"\065\100\111\110\105\115",V)else h("\065\068\079\078\073\083 \067\082\073\084\073\067\065\076 \087\065\082\078\073\078\071\033 \077\065\076\073\067\073\079\085\083 \067\079\068\069 \073\083 \084\082\089\073\078\071 \084\079 \067\072\065\078\071\069 \084\072\069 \065\068\079\078\073\083 \095\071 \065\080\073 \065\078\068 \073\084 \067\065\078\'\084 \066\069 \083\069\084 \066\065\067\075\033 \080\076\069\065\083\069 \083\072\085\084\068\079\087\078 \084\072\069 \083\069\082\086\069\082 \065\078\068 \082\069\077\079\086\069 \084\072\069 \077\065\076\073\067\073\079\085\083 \067\079\068\069 \073\070 \080\079\083\083\073\066\076\069\033")end end end,true)else h("\084\104\101 \095\071 \116\097\098\108\101 \119\097\115 \108\111\099\107\101\100 \097\110\100 \116\104\101 \065\100\111\110\105\115 \095\071 \065\080\073 \099\111\117\108\100 \110\111\116 \098\101 \108\111\097\100\101\100")end end end}end

return function(Vargs, GetEnv)
	local env = GetEnv(nil, {script = script})
	setfenv(1, env)

	local _G, game, script, getfenv, setfenv, workspace,
		getmetatable, setmetatable, loadstring, coroutine,
		rawequal, typeof, print, math, warn, error,  pcall,
		xpcall, select, rawset, rawget, ipairs, pairs,
		next, Rect, Axes, os, time, Faces, unpack, string, Color3,
		newproxy, tostring, tonumber, Instance, TweenInfo, BrickColor,
		NumberRange, ColorSequence, NumberSequence, ColorSequenceKeypoint,
		NumberSequenceKeypoint, PhysicalProperties, Region3int16,
		Vector3int16, require, table, type, wait,
		Enum, UDim, UDim2, Vector2, Vector3, Region3, CFrame, Ray, delay =
		_G, game, script, getfenv, setfenv, workspace,
		getmetatable, setmetatable, loadstring, coroutine,
		rawequal, typeof, print, math, warn, error,  pcall,
		xpcall, select, rawset, rawget, ipairs, pairs,
		next, Rect, Axes, os, time, Faces, unpack, string, Color3,
		newproxy, tostring, tonumber, Instance, TweenInfo, BrickColor,
		NumberRange, ColorSequence, NumberSequence, ColorSequenceKeypoint,
		NumberSequenceKeypoint, PhysicalProperties, Region3int16,
		Vector3int16, require, table, type, wait,
		Enum, UDim, UDim2, Vector2, Vector3, Region3, CFrame, Ray, delay

	local script = script
	local service = Vargs.Service
	local client = Vargs.Client
	local Anti, Core, Functions, Process, Remote, UI, Variables
	local function Init()
		UI = client.UI;
		Anti = client.Anti;
		Core = client.Core;
		Variables = client.Variables
		Functions = client.Functions;
		Process = client.Process;
		Remote = client.Remote;

		Core.Name = "\0"
		Core.Special = client.DepsName
		Core.MakeGui = UI.Make;
		Core.GetGui = UI.Get;
		Core.RemoveGui = UI.Remove;

		Core.Init = nil;
	end

	local function RunAfterPlugins(data)
		Core.GetEvent()

		Core.RunAfterPlugins = nil;
	end

	local function RunLast()
		--// API
		if service.NetworkClient then
			service.TrackTask("Thread: API Manager", Core.StartAPI)
			--service.Threads.RunTask("_G API Manager",client.Core.StartAPI)
		end

		--[[client = service.ReadOnly(client, {
				[client.Variables] = true;
				[client.Handlers] = true;
				G_API = true;
				G_Access = true;
				G_Access_Key = true;
				G_Access_Perms = true;
				Allowed_API_Calls = true;
				HelpButtonImage = true;
				Finish_Loading = true;
				RemoteEvent = true;
				ScriptCache = true;
				Returns = true;
				PendingReturns = true;
				EncodeCache = true;
				DecodeCache = true;
				Received = true;
				Sent = true;
				Service = true;
				Holder = true;
				GUIs = true;
				LastUpdate = true;
				RateLimits = true;

				Init = true;
				RunLast = true;
				RunAfterInit = true;
				RunAfterLoaded = true;
				RunAfterPlugins = true;
		}, true)--]]

		Core.RunLast = nil
	end

	getfenv().client = nil
	getfenv().service = nil
	getfenv().script = nil

	client.Core = {
		Init = Init;
		RunLast = RunLast;
		--RunAfterLoaded = RunAfterLoaded;
		RunAfterPlugins = RunAfterPlugins;
		Name = script.Name;
		Special = script.Name;
		ScriptCache = {};

		GetEvent = function()
			if Core.RemoteEvent then
				log("Disconnect old RemoteEvent")

				for name,event in next,Core.RemoteEvent.Events do
					event:Disconnect()
				end

				Core.RemoteEvent = nil;
			end

			log("Getting RemoteEvent");

			local eventData = {}
			local remoteParent = service.ReplicatedStorage;
			local event = remoteParent:WaitForChild(client.RemoteName, 300)

			if not event then
				Anti.Detected("Kick", "RemoteEvent Not Found");
			else
				log("Getting RemoteFunction");

				local rFunc = event:WaitForChild("__FUNCTION", 120);

				if not rFunc then
					Anti.Detected("Kick", "RemoteFunction Not Found");
				else
					local events = {};

					rFunc.OnClientInvoke = Process.Remote;

					eventData.Object = event;
					eventData.Function = rFunc;
					eventData.FireServer = event.FireServer;
					eventData.Events = events;

					events.ProcessRemote = event.OnClientEvent:Connect(Process.Remote)
					events.ParentChildRemoved = remoteParent.ChildRemoved:Connect(function(child)
						if (Core.RemoteEvent == eventData) and child == event and wait() then
							warn("::ADONIS:: REMOTE EVENT REMOVED? RE-GRABBING");
							log("~! REMOTEEVENT WAS REMOVED?")
							Core.GetEvent();
						end
					end)

					Core.RemoteEvent = eventData

					if not Core.Key then
						log("~! Getting key from server")
						Remote.Fire(client.DepsName.."GET_KEY")
					end
				end
			end
		end;

		LoadPlugin = function(plugin)
			local plug = require(plugin)
			local func = setfenv(plug,GetEnv(getfenv(plug)))
			cPcall(func)
		end;

		LoadBytecode = function(str, env)
			return require(client.Shared.FiOne)(str, env)
		end;

		LoadCode = function(str, env)
			return Core.LoadBytecode(str, env)
		end;

		StartAPI = function()
			local ScriptCache = Core.ScriptCache
			local FiOne = client.Shared.FiOne
			local Get = Remote.Get
			local GetFire = Remote.GetFire
			local G_API = client.G_API
			local Allowed_API_Calls = client.Allowed_API_Calls
			local NewProxy = service.NewProxy
			local MetaFunc = service.MetaFunc
			local ReadOnly = service.ReadOnly
			local StartLoop = service.StartLoop
			local ReadOnly = service.ReadOnly
			local UnWrap = service.UnWrap
			local service = nil
			local client = nil
			local _G = _G
			local setmetatable = setmetatable
			local type = type
			local print = print
			local error = error
			local pairs = pairs
			local warn = warn
			local next = next
			local table = table
			local rawset = rawset
			local rawget = rawget
			local getfenv = getfenv
			local setfenv = setfenv
			local require = require
			local tostring = tostring
			local client = client
			local Routine = Routine
			local cPcall = cPcall

			--// Get Settings
			local API_Special = {

			}

			setfenv(1,setmetatable({}, {__metatable = getmetatable(getfenv())}))

			local API_Specific = {
				API_Specific = {
					Test = function()
						print("We ran the api specific stuff")
					end
				};
				Service = service;
			}

			local API = {
				Access = ReadOnly({}, nil, nil, true);
				--[[
				Access = service.MetaFunc(function(...)
					local args = {...}
					local key = args[1]
					local ind = args[2]
					local targ

					setfenv(1,setmetatable({}, {__metatable = getmetatable(getfenv())}))

					if API_Specific[ind] then
						targ = API_Specific[ind]
					elseif client[ind] and client.Allowed_API_Calls[ind] then
						targ = client[ind]
					end

					if client.G_Access and key == client.G_Access_Key and targ and client.Allowed_API_Calls[ind] then
						if type(targ) == "table" then
							return service.NewProxy {
								__index = function(tab,inde)
									if targ[inde] ~= nil and API_Special[inde] == nil or API_Special[inde] == true then
										if targ[inde]~=nil and type(targ[inde]) == "table" and client.G_Access_Perms == "Read" then
											return service.ReadOnly(targ[inde])
										else
											return targ[inde]
										end
									elseif API_Special[inde] == false then
										error("Access Denied: "..tostring(inde))
									else
										error("Could not find "..tostring(inde))
									end
								end;
								__newindex = function(tabl,inde,valu)
									error("Read-only")
								end;
								__metatable = true;
							}
						end
					else
						error("Incorrect key or G_Access is disabled")
					end
				end);
				--]]

				Scripts = ReadOnly({
					ExecutePermission = (function(srcScript, code)
						local exists;

						for i,v in next,ScriptCache do
							if UnWrap(v.Script) == srcScript then
								exists = v
							end
						end

						if exists and exists.noCache ~= true and (not exists.runLimit or (exists.runLimit and exists.Executions <= exists.runLimit)) then
							exists.Executions = exists.Executions+1
							return exists.Source, exists.Loadstring
						end

						local data = Get("ExecutePermission", srcScript, code, true)
						if data and data.Source then
							local module;
							if not exists then
								module = require(FiOne:Clone())
								table.insert(ScriptCache,{
									Script = srcScript;
									Source = data.Source;
									Loadstring = module;
									noCache = data.noCache;
									runLimit = data.runLimit;
									Executions = data.Executions;
								})
							else
								module = exists.Loadstring
								exists.Source = data.Source
							end
							return data.Source, module
						end
					end);
				}, nil, nil, true);
			}

			local AdonisGTable = NewProxy({
				__index = function(tab,ind)
					if ind == "Scripts" then
						return API.Scripts
					elseif G_API and Allowed_API_Calls.Client == true then
						if type(API[ind]) == "function" then
							return MetaFunc(API[ind])
						else
							return API[ind]
						end
					else
						error("_G API is disabled")
					end
				end;
				__newindex = function()
					error("Read-only")
				end;
				__metatable = "API";
			})

			if not rawget(_G, "Adonis") then
				if table.isfrozen and not table.isfrozen(_G) or not table.isfrozen then
					rawset(_G, "Adonis", AdonisGTable)
					StartLoop("APICheck", 1, function()
						if rawget(_G, "Adonis") ~= AdonisGTable then
							if table.isfrozen and not table.isfrozen(_G) or not table.isfrozen then
								rawset(_G, "Adonis", AdonisGTable)
							else
								warn("ADONIS CRITICAL WARNING! MALICIOUS CODE IS TRYING TO CHANGE THE ADONIS _G API AND IT CAN'T BE SET BACK! PLEASE SHUTDOWN THE SERVER AND REMOVE THE MALICIOUS CODE IF POSSIBLE!")
							end
						end
					end, true)
				else
					warn("The _G table was locked and the Adonis _G API could not be loaded")
				end
			end
		end;
	};
end
