return function()local w,n,N,X,t,H,q,R,d,p local function B()w=server.Functions n=server.Admin N=server.Anti X=server.Core t=server.HTTP H=server.Logs q=server.Remote R=server.Process d=server.Variables p=server.Settings H:AddLog("\083\099\114\105\112\116","\070\117\110\099\116\105\111\110\115 \077\111\100\117\108\101 \073\110\105\116\105\097\108\105\122\101\100")end server.Functions={Init=B,PlayerFinders={me={Match="\109\101",Prefix=true;Absolute=true;Function=function(w,n,N,X,t,H,q)table.insert(X,n)H()end};all={Match="\097\108\108";Prefix=true;Absolute=true;Function=function(w,n,N,X,t,H,q)local R=true if q then for n,N in next,N:GetChildren()do local q=t(N)if(q.Name:lower()):sub(1,#w)==w:lower()then R=false table.insert(X,q)H()end end end if R then for w,n in next,N:GetChildren()do local N=t(n)if N then table.insert(X,N)H()end end end end},["\064\101\118\101\114\121\111\110\101"]={Match="\064\101\118\101\114\121\111\110\101",Absolute=true,Function=function(...)return w.PlayerMatchers.all.Function(...)end};others={Match="\111\116\104\101\114\115",Prefix=true;Absolute=true,Function=function(w,n,N,X,t,H,q)for w,N in next,N:GetChildren()do local q=t(N)if q~=n then table.insert(X,q)H()end end end},random={Match="\114\097\110\100\111\109";Prefix=true,Absolute=true,Function=function(n,N,X,t,H,q,R)if#t>=#X:GetChildren()then return end local d=(X:GetChildren())[math.random(#X:children())]local p=H(d)for d,B in pairs(t)do if B.Name==p.Name then w.PlayerFinders.random.Function(n,N,X,t,H,q,R)return end end table.insert(t,p)q()end},admins={Match="\097\100\109\105\110\115",Prefix=true;Absolute=true;Function=function(w,N,X,t,H,q,R)for w,N in next,X:children()do local X=H(N)if n.CheckAdmin(X,false)then table.insert(t,X)q()end end end},nonadmins={Match="\110\111\110\097\100\109\105\110\115",Prefix=true,Absolute=true;Function=function(w,N,X,t,H,q,R)for w,N in next,X:children()do local X=H(N)if not n.CheckAdmin(X,false)then table.insert(t,X)q()end end end};friends={Match="\102\114\105\101\110\100\115",Prefix=true,Absolute=true,Function=function(w,n,N,X,t,H,q)for w,N in next,N:children()do local q=t(N)if q:IsFriendsWith(n.userId)then table.insert(X,q)H()end end end};["\037\116\101\097\109"]={Match="\037";Function=function(w,n,N,X,t,H,q)local R=w:match("\037\037\040\046\042\041")if R then for w,n in next,service.Teams:GetChildren()do if(n.Name:lower()):sub(1,#R)==R:lower()then for w,N in next,N:GetChildren()do local q=t(N)if q.TeamColor==n.TeamColor then table.insert(X,q)H()end end end end end end};["\036\103\114\111\117\112"]={Match="\036",Function=function(w,n,N,X,t,H,q)local R=w:match("\037\036\040\046\042\041")if R and tonumber(R)then for w,n in next,N:children()do local N=t(n)if N:IsInGroup(tonumber(R))then table.insert(X,N)H()end end end end};["\105\100-"]={Match="\105\100-";Function=function(w,n,N,X,t,H,q)local R=tonumber(w:match("\105\100\037-\040\046\042\041"))local d=0 if R then for w,n in next,N:children()do local N=t(n)if N and N.userId==R then table.insert(X,N)H()d=d+1 end end if d==0 then local w,n=pcall(function()return service.Players:GetNameFromUserIdAsync(R)end)if w and n then local w=service.Wrap(service.New("\070\111\108\100\101\114"))local N={Name=n;ToString=n,ClassName="\080\108\097\121\101\114",AccountAge=0;CharacterAppearanceId=tostring(R),UserId=tonumber(R);userId=tonumber(R);Parent=service.Players;Character=Instance.new("\077\111\100\101\108");Backpack=Instance.new("\070\111\108\100\101\114");PlayerGui=Instance.new("\070\111\108\100\101\114"),PlayerScripts=Instance.new("\070\111\108\100\101\114"),Kick=function()w:Destroy()w:SetSpecial("\080\097\114\101\110\116",nil)end;IsA=function(w,n)if n=="\080\108\097\121\101\114"then return true end end}for n,N in next,N do w:SetSpecial(n,N)end table.insert(X,w)H()end end end end},["\116\101\097\109-"]={Match="\116\101\097\109-",Function=function(w,n,N,X,t,H,q)print(1)local R=w:match("\116\101\097\109\037-\040\046\042\041")if R then for w,n in next,service.Teams:GetChildren()do if(n.Name:lower()):sub(1,#R)==R:lower()then for w,N in next,N:GetChildren()do local q=t(N)if q.TeamColor==n.TeamColor then table.insert(X,q)H()end end end end end end},["\103\114\111\117\112-"]={Match="\103\114\111\117\112-";Function=function(w,n,N,X,t,H,q)local R=w:match("\103\114\111\117\112\037-\040\046\042\041")if R and tonumber(R)then for w,n in next,N:children()do local N=t(n)if N:IsInGroup(tonumber(R))then table.insert(X,N)H()end end end end},["-\110\097\109\101"]={Match="-";Function=function(w,n,N,X,t,H,q)local R=w:match("\037-\040\046\042\041")if R then local w=service.GetPlayers(n,R,true)for n,N in next,X do for w,t in next,w do if N.Name==t.Name then table.remove(X,n)H()end end end end end},["\035\110\117\109\098\101\114"]={Match="\035",Function=function(n,N,...)local X=n:match("\037\035\040\046\042\041")if X and tonumber(X)then local t=tonumber(X)if not t then q.MakeGui(N,"\079\117\116\112\117\116",{Title="\079\117\116\112\117\116",Message="\073\110\118\097\108\105\100 \110\117\109\098\101\114\033"})end for X=1,t,1 do w.PlayerFinders.random.Function(n,N,...)end end end};["\114\097\100\105\117\115-"]={Match="\114\097\100\105\117\115-",Function=function(w,n,N,X,t,H,R)local d=w:match("\114\097\100\105\117\115\037-\040\046\042\041")if d and tonumber(d)then local w=tonumber(d)if not w then q.MakeGui(n,"\079\117\116\112\117\116",{Title="\079\117\116\112\117\116";Message="\073\110\118\097\108\105\100 \110\117\109\098\101\114\033"})end for N,q in next,N:GetChildren()do local R=t(q)if R~=n and n:DistanceFromCharacter(R.Character.Head.Position)<=w then table.insert(X,R)H()end end end end}},IsClass=function(w,n)for n,N in next,n do if w:IsA(N)then return true end end end,PerformOnEach=function(w,n,...)for w,N in next,w do pcall(n,N,...)end end,ArgsToString=function(w)local n=""for w,N in next,w do n=n..("\065\114\103"..(tostring(w)..("\058 "..(tostring(N).."\059 "))))end return n end,GetPlayers=function(N,X,t,H,R,B)local T={}local Z=p.SpecialPrefix if H then Z=""end local x=service.NetworkServer or service.Players local function e(w)if w and w:IsA("\080\108\097\121\101\114")then return w elseif w and w:IsA("\078\101\116\119\111\114\107\082\101\112\108\105\099\097\116\111\114")then if w:GetPlayer()~=nil and(w:GetPlayer()):IsA("\080\108\097\121\101\114")then return w:GetPlayer()end end end local function f(X)for w,t in next,w.PlayerFinders do if not t.Level or t.Level and n.GetLevel(N)>=t.Level then local w=(t.Prefix and p.SpecialPrefix or"")..t.Match if t.Absolute and X:lower()==w or not t.Absolute and(X:lower()):sub(1,#w)==w:lower()then return t end end end end if N==nil then for w,n in pairs(x:GetChildren())do local N=e(n)if N then table.insert(T,N)end end elseif N and not X then return{N}else if(X:lower()):sub(1,2)=="\035\035"then error("\083\116\114\105\110\103 \112\097\115\115\101\100 \116\111 \071\101\116\080\108\097\121\101\114\115 \105\115 \102\105\108\116\101\114\101\100\058 "..tostring(X))else for w in X:gmatch("\040\091\094\044\093\043\041")do local n=0 local function X()n=n+1 end local d=f(w)if d then d.Function(w,N,x,T,e,X,R,H,t)else for n,N in next,x:children()do local t=e(N)if t and(t.Name:lower()):sub(1,#w)==w:lower()then table.insert(T,t)X()end end if n==0 then local n,N=pcall(function()return service.Players:GetUserIdFromNameAsync(w)end)if n and tonumber(N)then local n=service.Wrap(service.New("\070\111\108\100\101\114"))local t={Name=w,ToString=w;ClassName="\080\108\097\121\101\114";AccountAge=0;CharacterAppearanceId=tostring(N);UserId=tonumber(N),userId=tonumber(N),Parent=service.Players;Character=Instance.new("\077\111\100\101\108"),Backpack=Instance.new("\070\111\108\100\101\114"),PlayerGui=Instance.new("\070\111\108\100\101\114");PlayerScripts=Instance.new("\070\111\108\100\101\114"),Kick=function()n:Destroy()n:SetSpecial("\080\097\114\101\110\116",nil)end,IsA=function(w,n)if n=="\080\108\097\121\101\114"then return true end end}for w,N in next,t do n:SetSpecial(w,N)end table.insert(T,n)X()end end end if n==0 and not t then q.MakeGui(N,"\079\117\116\112\117\116",{Title="\079\117\116\112\117\116";Message="\078\111 \112\108\097\121\101\114\115 \109\097\116\099\104\105\110\103 "..(w.." \119\101\114\101 \102\111\117\110\100\033")})end end end end if not R then for w,n in pairs(T)do for X,t in pairs(d.NOU)do if N==t.Target and n==t.User then table.remove(T,w)table.insert(T,w,N)end end end end return T end;GetRandom=function(w)local n=type(w)=="\110\117\109\098\101\114"and w or math.random(5,10)local N={}for w=1,n,1 do N[w]=string.format("\037\048\050\120",math.random(126))end return table.concat(N)end;Base64Encode=function(w)local n="\065\066\067\068\069\070\071\072\073\074\075\076\077\078\079\080\081\082\083\084\085\086\087\088\089\090\097\098\099\100\101\102\103\104\105\106\107\108\109\110\111\112\113\114\115\116\117\118\119\120\121\122\048\049\050\051\052\053\054\055\056\057\043\047"return(w:gsub("\046",function(w)local n,N="",w:byte()for w=8,1,-1 do n=n..(N%2^w-N%2^(w-1)>0 and"\049"or"\048")end return n end).."\048\048\048\048"):gsub("\037\100\037\100\037\100\063\037\100\063\037\100\063\037\100\063",function(w)if#w<6 then return""end local N=0 for n=1,6,1 do N=N+(w:sub(n,n)=="\049"and 2^(6-n)or 0)end return n:sub(N+1,N+1)end)..({"","\061\061";"\061"})[#w%3+1]end;Base64Decode=function(w)local n="\065\066\067\068\069\070\071\072\073\074\075\076\077\078\079\080\081\082\083\084\085\086\087\088\089\090\097\098\099\100\101\102\103\104\105\106\107\108\109\110\111\112\113\114\115\116\117\118\119\120\121\122\048\049\050\051\052\053\054\055\056\057\043\047"w=string.gsub(w,"\091\094"..(n.."\061\093"),"")return(w:gsub("\046",function(w)if w=="\061"then return""end local N,X="",n:find(w)-1 for w=6,1,-1 do N=N..(X%2^w-X%2^(w-1)>0 and"\049"or"\048")end return N end)):gsub("\037\100\037\100\037\100\063\037\100\063\037\100\063\037\100\063\037\100\063\037\100\063",function(w)if#w~=8 then return""end local n=0 for N=1,8,1 do n=n+(w:sub(N,N)=="\049"and 2^(7-N)or 0)end return string.char(n)end)end,Hint=function(w,n,N)for n,X in pairs(n)do q.MakeGui(X,"\072\105\110\116",{Message=w;Time=N})end end,Message=function(w,n,N,X,t)for N,H in pairs(N)do q.RemoveGui(H,"\077\101\115\115\097\103\101")q.MakeGui(H,"\077\101\115\115\097\103\101",{Title=w;Message=n,Scroll=X,Time=t})end end,Notify=function(w,n,N,X)for N,t in pairs(N)do q.RemoveGui(t,"\078\111\116\105\102\121")q.MakeGui(t,"\078\111\116\105\102\121",{Title=w;Message=n;Time=X})end end,MakeWeld=function(w,n)local N=service.New("\077\097\110\117\097\108\087\101\108\100",w)N.Part0=w N.Part1=n N.C0=w.CFrame:inverse()*n.CFrame return N end,SetView=function(w)if w=="\114\101\115\101\116"then workspace.CurrentCamera.CameraType="\067\117\115\116\111\109"workspace.CurrentCamera.CameraSubject=service.Player.Character.Humanoid workspace.CurrentCamera.FieldOfView=70 else workspace.CurrentCamera.CameraSubject=w end end;SetLighting=function(w,n)if service.Lighting[w]~=nil then service.Lighting[w]=n d.LightingSettings[w]=n for N,X in pairs(service.GetPlayers())do q.SetLighting(X,w,n)end end end,LoadEffects=function(w)for n,N in pairs(d.LocalEffects)do if N.Part and N.Part.Parent or N.NoPart then if N.Type=="\067\097\112\101"then q.Send(w,"\070\117\110\099\116\105\111\110","\078\101\119\067\097\112\101",N.Data)elseif N.Type=="\080\097\114\116\105\099\108\101"then q.NewParticle(w,N.Part,N.Class,N.Props)end else d.LocalEffects[n]=nil end end end,NewParticle=function(n,N,X)local t=w.GetRandom()d.LocalEffects[t]={Part=n;Class=N,Props=X,Type="\080\097\114\116\105\099\108\101"}for w,t in next,service.Players:GetPlayers()do q.NewParticle(t,n,N,X)end end;RemoveParticle=function(w,n)for N,X in next,d.LocalEffects do if X.Type=="\080\097\114\116\105\099\108\101"and(X.Part==w and(X.Props.Name==n or X.Class==n))then d.LocalEffects[N]=nil end end for N,X in next,service.Players:GetPlayers()do q.RemoveParticle(X,w,n)end end;UnCape=function(w)for n,N in pairs(d.LocalEffects)do if N.Type=="\067\097\112\101"and N.Player==w then d.LocalEffects[n]=nil end end for n,N in pairs(service.GetPlayers())do q.Send(N,"\070\117\110\099\116\105\111\110","\082\101\109\111\118\101\067\097\112\101",w.Character)end end,Cape=function(n,N,X,t,H,R)w.UnCape(n)local B=n.Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if B then if type(t)=="\116\097\098\108\101"then t=Color3.new(t[1],t[2],t[3])end local B={Color=t,Parent=n.Character;Material=X;Reflectance=R;Decal=H}if N and(p.DonorCapes and p.LocalCapes)then q.Send(n,"\070\117\110\099\116\105\111\110","\078\101\119\067\097\112\101",B)else local N=w.GetRandom()d.LocalEffects[N]={Player=n;Part=n.Character.HumanoidRootPart,Data=B;Type="\067\097\112\101"}for w,n in pairs(service.GetPlayers())do q.Send(n,"\070\117\110\099\116\105\111\110","\078\101\119\067\097\112\101",B)end end end end,LoadOnClient=function(n,N,t,H)if service.Players:FindFirstChild(n.Name)then local q=n:FindFirstChild("\080\108\097\121\101\114\071\117\105")or n:WaitForChild("\066\097\099\107\112\097\099\107")local R=X.NewScript("\076\111\099\097\108\083\099\114\105\112\116",N)R.Name=H or w.GetRandom()R.Parent=q R.Disabled=false if t then table.insert(d.Objects,R)end end end;Split=function(w,n,N)if not w or not n or not N or N<=0 then return{}end if n==""then n=" "end local X={}local t=""for H in w:gmatch("\040\091\094"..(n.."\093\043\041"))do if#X>=N then break elseif#X>=N-1 then table.insert(X,w:sub(#t+1,#w))else t=t..(H..n)table.insert(X,H)end end return X end;BasicSplit=function(w,n)local N={}for w in w:gmatch("\040\091\094"..(n.."\093\043\041"))do table.insert(N,w)end return N end,CountTable=function(w)local n=0 for w in pairs(w)do n=n+1 end return n end;GetTexture=function(n)n=w.Trim(tostring(n))local N if not tonumber(n)then return false else n=tonumber(n)end if not pcall(function()updated=(service.MarketPlace:GetProductInfo(n)).Created:match("\037\100\043-\037\100\043-\037\083\043\058\037\100\043")end)then return false end for w=0,10,1 do local N local X,t=pcall(function()N=service.MarketPlace:GetProductInfo(n-w)end)if X then if N.AssetTypeId==1 and N.Created:match("\037\100\043-\037\100\043-\037\083\043\058\037\100\043")==updated then return n-w end end end end,Trim=function(w)return w:match("\094\037\115\042\040\046-\041\037\115\042\036")end,Round=function(w)return math.floor(w+.5)end,RoundToPlace=function(w,n)return math.floor(w*10^(n or 0)+.5)/10^(n or 0)end,GetOldDonorList=function()local w={}for n,N in pairs(service.InsertService:GetCollection(1290539))do local X=service.MarketPlace:GetProductInfo(N.AssetId)local t=X.Description for n in t:gmatch("\091\094\059\093\043")do local N,t,H,q=n:match("\123\040\046\042\041\044\040\046\042\041\044\040\046\042\041\044\040\046\042\041\125")table.insert(w,{Name=N;Id=tostring(t),Cape=tostring(H),Color=q;Material="\080\108\097\115\116\105\099",List=X.Name})end end d.OldDonorList=w end;CleanWorkspace=function()for w,n in pairs(service.Workspace:children())do if n:IsA("\084\111\111\108")or n:IsA("\065\099\099\101\115\115\111\114\121")or n:IsA("\072\097\116")then n:Destroy()end end end;GrabNilPlayers=function(w)local n={}for N,X in pairs(service.NetworkServer:GetChildren())do pcall(function()if X:IsA("\083\101\114\118\101\114\082\101\112\108\105\099\097\116\111\114")then if((X:GetPlayer()).Name:lower()):sub(1,#w)==w:lower()or w=="\097\108\108"then table.insert(n,X:GetPlayer()or"\078\111\080\108\097\121\101\114")end end end)end return n end;AssignName=function()local w=math.random(100000,999999)return w end;Shutdown=function(n)if not X.PanicMode then w.Message("\083\089\083\084\069\077 \077\069\083\083\065\071\069","\083\104\117\116\116\105\110\103 \100\111\119\110\046\046\046",service.Players:GetChildren(),false,5)wait(1)end service.Players.PlayerAdded:connect(function(w)w:Kick("\071\097\109\101 \115\104\117\116\100\111\119\110\058 "..tostring(n or"\078\111 \082\101\097\115\111\110 \071\105\118\101\110"))end)for w,N in pairs(service.NetworkServer:children())do service.Routine(function()if N and N:GetPlayer()then(N:GetPlayer()):Kick("\071\097\109\101 \115\104\117\116\100\111\119\110\058 "..tostring(n or"\078\111 \082\101\097\115\111\110 \071\105\118\101\110"))wait(30)if N.Parent and N:GetPlayer()then q.Send(N:GetPlayer(),"\070\117\110\099\116\105\111\110","\075\105\108\108\067\108\105\101\110\116")end end end)end end;Donor=function(N)if n.CheckDonor(N)and p.DonorCapes then local n=X.GetPlayer(N)or{Donor={}}local t=n.Donor or{}if t and t.Enabled then local n,X,H if t and t.Cape then n,X,H=t.Cape.Image,t.Cape.Color,t.Cape.Material else n,X,H="\048","\087\104\105\116\101","\078\101\111\110"end if N and(N.Character and N.Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"))then w.Cape(N,true,H,X,n)end end end end,CheckMatch=function(n,N)if n==N then return true elseif type(n)=="\116\097\098\108\101"and type(N)=="\116\097\098\108\101"then local X=false local t=0 for w,n in pairs(n)do if n==N[w]then X=true else X=false break end t=t+1 end if X and t==w.CountTable(n)then return true end end end,GetIndex=function(w,n)for w,N in pairs(w)do if N==n then return w elseif type(N)=="\116\097\098\108\101"and type(n)=="\116\097\098\108\101"then local X=false for w,N in pairs(N)do if N==n[w]then X=true else X=false break end end if X then return w end end end end}end

return function()
	local Functions, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Settings
	local function Init()
		Functions = server.Functions;
		Admin = server.Admin;
		Anti = server.Anti;
		Core = server.Core;
		HTTP = server.HTTP;
		Logs = server.Logs;
		Remote = server.Remote;
		Process = server.Process;
		Variables = server.Variables;
		Settings = server.Settings;
		
		Logs:AddLog("Script", "Functions Module Initialized")
	end;
	
	server.Functions = {
		Init = Init;
		PlayerFinders = {
			["me"] = {
				Match = "me";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					table.insert(players,plr)
					plus()
				end;
			};
			
			["all"] = {
				Match = "all";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local everyone = true
					if isKicking then
						for i,v in next,parent:GetChildren() do
							local p = getplr(v)
							if p.Name:lower():sub(1,#msg)==msg:lower() then
								everyone = false
								table.insert(players,p)
								plus()
							end
						end
					end
							
					if everyone then
						for i,v in next,parent:GetChildren() do
							local p = getplr(v)
							if p then
								table.insert(players,p)
								plus()
							end
						end
					end
				end;
			};
			
			["@everyone"] = {
				Match = "@everyone";
				Absolute = true;
				Function = function(...)
					return Functions.PlayerMatchers.all.Function(...)
				end
			};
			
			["others"] = {
				Match = "others";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					for i,v in next,parent:GetChildren() do
						local p = getplr(v)
						if p ~= plr then
							table.insert(players,p)
							plus()
						end
					end
				end;
			};
			
			["random"] = {
				Match = "random";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					if #players>=#parent:GetChildren() then return end
					local rand = parent:GetChildren()[math.random(#parent:children())]
					local p = getplr(rand)
					
					for i,v in pairs(players) do
						if(v.Name == p.Name)then
							Functions.PlayerFinders.random.Function(msg, plr, parent, players, getplr, plus, isKicking)
							return;
						end
					end
					
					table.insert(players,p)
					plus();
				end;
			};
			
			["admins"] = {
				Match = "admins";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					for i,v in next,parent:children() do
						local p = getplr(v)
						if Admin.CheckAdmin(p,false) then
							table.insert(players, p)
							plus()
						end
					end
				end;
			};
			
			["nonadmins"] = {
				Match = "nonadmins";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					for i,v in next,parent:children() do
						local p = getplr(v)
						if not Admin.CheckAdmin(p,false) then
							table.insert(players,p)
							plus()
						end
					end
				end;
			};
			
			["friends"] = {
				Match = "friends";
				Prefix = true;
				Absolute = true;
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					for i,v in next,parent:children() do
						local p = getplr(v)
						if p:IsFriendsWith(plr.userId) then
							table.insert(players,p)
							plus()
						end
					end
				end;
			};
			
			["%team"] = {
				Match = "%";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local matched = msg:match("%%(.*)")
					if matched then
						for i,v in next,service.Teams:GetChildren() do
							if v.Name:lower():sub(1,#matched) == matched:lower() then
								for k,m in next,parent:GetChildren() do
									local p = getplr(m)
									if p.TeamColor == v.TeamColor then
										table.insert(players,p)
										plus()
									end
								end
							end
						end
					end
				end;
			};
			
			["$group"] = {
				Match = "$";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local matched = msg:match("%$(.*)")
					if matched and tonumber(matched) then
						for i,v in next,parent:children() do
							local p = getplr(v)
							if p:IsInGroup(tonumber(matched)) then
								table.insert(players,p)
								plus()
							end
						end
					end
				end;
			};
			
			["id-"] = {
				Match = "id-";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local matched = tonumber(msg:match("id%-(.*)"))
					local foundNum = 0
					if matched then
						for i,v in next,parent:children() do
							local p = getplr(v)
							if p and p.userId == matched then
								table.insert(players,p)
								plus()
								foundNum = foundNum+1
							end
						end
						
						if foundNum == 0 then
							local ran,name = pcall(function() return service.Players:GetNameFromUserIdAsync(matched) end)
							if ran and name then
								local fakePlayer = service.Wrap(service.New("Folder"))
								local data = {
									Name = name;
									ToString = name;
									ClassName = "Player";
									AccountAge = 0;
									CharacterAppearanceId = tostring(matched);
									UserId = tonumber(matched);
									userId = tonumber(matched);
									Parent = service.Players;
									Character = Instance.new("Model");
									Backpack = Instance.new("Folder");
									PlayerGui = Instance.new("Folder");
									PlayerScripts = Instance.new("Folder");
									Kick = function() fakePlayer:Destroy() fakePlayer:SetSpecial("Parent", nil) end;
									IsA = function(ignore, arg) if arg == "Player" then return true end end;
								}
								for i,v in next,data do fakePlayer:SetSpecial(i, v) end
								table.insert(players, fakePlayer)
								plus()
							end
						end
					end
				end;
			};
			
			["team-"] = {
				Match = "team-";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					print(1)
					local matched = msg:match("team%-(.*)")
					if matched then
						for i,v in next,service.Teams:GetChildren() do
							if v.Name:lower():sub(1,#matched) == matched:lower() then
								for k,m in next,parent:GetChildren() do
									local p = getplr(m)
									if p.TeamColor == v.TeamColor then
										table.insert(players, p)
										plus()
									end
								end
							end
						end
					end
				end;
			};
			
			["group-"] = {
				Match = "group-";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local matched = msg:match("group%-(.*)")
					if matched and tonumber(matched) then
						for i,v in next,parent:children() do
							local p = getplr(v)
							if p:IsInGroup(tonumber(matched)) then
								table.insert(players,p)
								plus()
							end
						end
					end
				end;
			};
			
			["-name"] = {
				Match = "-";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local matched = msg:match("%-(.*)")
					if matched then
						local removes = service.GetPlayers(plr,matched,true)
						for i,v in next,players do
							for k,p in next,removes do
								if v.Name == p.Name then
									table.remove(players,i)
									plus()
								end
							end
						end
					end
				end;
			};
			
			["#number"] = {
				Match = "#";
				Function = function(msg, plr, ...)
					local matched = msg:match("%#(.*)")
					if matched and tonumber(matched) then
						local num = tonumber(matched)
						if not num then
							Remote.MakeGui(plr,'Output',{Title = 'Output'; Message = "Invalid number!"})
						end
						
						for i = 1,num do
							Functions.PlayerFinders.random.Function(msg, plr, ...)
						end
					end
				end;
			};
			
			["radius-"] = {
				Match = "radius-";
				Function = function(msg, plr, parent, players, getplr, plus, isKicking)
					local matched = msg:match("radius%-(.*)")
					if matched and tonumber(matched) then
						local num = tonumber(matched)
						if not num then
							Remote.MakeGui(plr,'Output',{Title = 'Output'; Message = "Invalid number!"})
						end
						
						for i,v in next,parent:GetChildren() do
							local p = getplr(v)
							if p ~= plr and plr:DistanceFromCharacter(p.Character.Head.Position) <= num then
								table.insert(players,p)
								plus()
							end
						end
					end
				end;
			};			
		};
		
		IsClass = function(obj, classList)
			for _,class in next,classList do
				if obj:IsA(class) then
					return true
				end
			end
		end;
		
		PerformOnEach = function(itemList, func, ...)
			for i,v in next,itemList do
				pcall(func, v, ...)
			end
		end;
		
		ArgsToString = function(args)
			local str = ""
			for i,arg in next,args do
				str = str.."Arg"..tostring(i)..": "..tostring(arg).."; "
			end
			return str
		end;
		
		GetPlayers = function(plr, names, dontError, isServer, isKicking, noID)
			local players = {} 
			local prefix = Settings.SpecialPrefix
			if isServer then prefix = "" end
			local parent = service.NetworkServer or service.Players
			
			local function getplr(p)
				if p and p:IsA("Player") then
					return p
				elseif p and p:IsA('NetworkReplicator') then
					if p:GetPlayer()~=nil and p:GetPlayer():IsA('Player') then
						return p:GetPlayer()
					end
				end
			end
			
			local function checkMatch(msg)
				for ind, data in next, Functions.PlayerFinders do
					if not data.Level or (data.Level and Admin.GetLevel(plr) >= data.Level) then
						local check = ((data.Prefix and Settings.SpecialPrefix) or "")..data.Match
						if (data.Absolute and msg:lower() == check) or (not data.Absolute and msg:lower():sub(1,#check) == check:lower()) then
							return data
						end
					end
				end
			end
					
			if plr == nil then
				for i,v in pairs(parent:GetChildren()) do
					local p = getplr(v)
					if p then
						table.insert(players,p)
					end
				end
			elseif plr and not names then
				return {plr}
			else
				if names:lower():sub(1,2) == "##" then
					error("String passed to GetPlayers is filtered: "..tostring(names))
				else
					for s in names:gmatch('([^,]+)') do
						local plrs = 0
						local function plus()
							plrs = plrs+1
						end
						
						local matchFunc = checkMatch(s)
						if matchFunc then
							matchFunc.Function(s, plr, parent, players, getplr, plus, isKicking, isServer, dontError)
						else
							for i,v in next,parent:children() do
								local p = getplr(v)
								if p and p.Name:lower():sub(1,#s)==s:lower() then
									table.insert(players,p)
									plus()
								end
							end
							
							if plrs == 0 then
								local ran,userid = pcall(function() return service.Players:GetUserIdFromNameAsync(s) end)
								if ran and tonumber(userid) then
									local fakePlayer = service.Wrap(service.New("Folder"))
									local data = {
										Name = s;
										ToString = s;
										ClassName = "Player";
										AccountAge = 0;
										CharacterAppearanceId = tostring(userid);
										UserId = tonumber(userid);
										userId = tonumber(userid);
										Parent = service.Players;
										Character = Instance.new("Model");
										Backpack = Instance.new("Folder");
										PlayerGui = Instance.new("Folder");
										PlayerScripts = Instance.new("Folder");
										Kick = function() fakePlayer:Destroy() fakePlayer:SetSpecial("Parent", nil) end;
										IsA = function(ignore, arg) if arg == "Player" then return true end end;
									}
									for i,v in next,data do fakePlayer:SetSpecial(i, v) end
									table.insert(players, fakePlayer)
									plus()
								end
							end
						end
						
						if plrs == 0 and not dontError then 
							Remote.MakeGui(plr,'Output',{Title = 'Output'; Message = 'No players matching '..s..' were found!'}) 
						end
					end
				end
			end
			if not isKicking then
				for i,Player in pairs(players) do
					for _,Card in pairs(Variables.NOU) do
						if plr==Card.Target and Player==Card.User then
							table.remove(players,i)
							table.insert(players,i,plr)
						end
					end
				end
			end
			return players
		end;
		
		GetRandom = function(pLen)
			--local str = ""
			--for i=1,math.random(5,10) do str=str..string.char(math.random(33,90)) end
			--return str
			local Len = (type(pLen) == "number" and pLen) or math.random(5,10) --// reru
			local Res = {};
		    for Idx = 1, Len do
		        Res[Idx] = string.format('%02x', math.random(126));
		    end;
		    return table.concat(Res)
		end; 
		
		Base64Encode = function(data)
			local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
		    return ((data:gsub('.', function(x) 
		        local r,b='',x:byte()
		        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
		        return r;
		    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
		        if (#x < 6) then return '' end
		        local c=0
		        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
		        return b:sub(c+1,c+1)
		    end)..({ '', '==', '=' })[#data%3+1])
		end;
		
		Base64Decode = function(data)
			local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
		    data = string.gsub(data, '[^'..b..'=]', '')
		    return (data:gsub('.', function(x)
		        if (x == '=') then return '' end
		        local r,f='',(b:find(x)-1)
		        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
		        return r;
		    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
		        if (#x ~= 8) then return '' end
		        local c=0
		        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(7-i) or 0) end
		        return string.char(c)
			end))
		end;
		
		Hint = function(message,players,time)
			for i,v in pairs(players) do
				Remote.MakeGui(v,"Hint",{
					Message = message;
					Time = time;
				})
			end
		end;
		
		Message = function(title,message,players,scroll,tim)
			for i,v in pairs(players) do
				Remote.RemoveGui(v,"Message")
				Remote.MakeGui(v,"Message",{
					Title = title;
					Message = message;
					Scroll = scroll;
					Time = tim;
				})
			end
		end;
		
		Notify = function(title,message,players,tim)
			for i,v in pairs(players) do
				Remote.RemoveGui(v,"Notify")
				Remote.MakeGui(v,"Notify",{
					Title = title;
					Message = message;
					Time = tim;
				})
			end
		end;
		
		MakeWeld = function(a, b)
		  	local weld = service.New("ManualWeld", a)
		    weld.Part0 = a
		    weld.Part1 = b
		    weld.C0 = a.CFrame:inverse() * b.CFrame
		    return weld
		end;
		
		SetView = function(ob)
			if ob == 'reset' then
				workspace.CurrentCamera.CameraType = 'Custom' 
				workspace.CurrentCamera.CameraSubject = service.Player.Character.Humanoid
				workspace.CurrentCamera.FieldOfView = 70
			else
				workspace.CurrentCamera.CameraSubject = ob
			end
		end;
		
		SetLighting = function(prop,value)
			if service.Lighting[prop]~=nil then
				service.Lighting[prop] = value
				Variables.LightingSettings[prop] = value
				for ind,p in pairs(service.GetPlayers()) do
					Remote.SetLighting(p,prop,value)
				end
			end
		end;
		
		LoadEffects = function(plr)
			for i,v in pairs(Variables.LocalEffects) do
				if (v.Part and v.Part.Parent) or v.NoPart then
					if v.Type == "Cape" then
						Remote.Send(plr,"Function","NewCape",v.Data)
					elseif v.Type == "Particle" then
						Remote.NewParticle(plr,v.Part,v.Class,v.Props)
					end
				else
					Variables.LocalEffects[i] = nil
				end
			end
		end;
		
		NewParticle = function(target,type,props)
			local ind = Functions.GetRandom()
			Variables.LocalEffects[ind] = {
				Part = target;
				Class = type;
				Props = props;
				Type = "Particle";
			}
			for i,v in next,service.Players:GetPlayers() do
				Remote.NewParticle(v,target,type,props)
			end
		end;
		
		RemoveParticle = function(target,name)
			for i,v in next,Variables.LocalEffects do
				if v.Type == "Particle" and v.Part == target and (v.Props.Name == name or v.Class == name) then
					Variables.LocalEffects[i] = nil
				end
			end
			for i,v in next,service.Players:GetPlayers() do
				Remote.RemoveParticle(v,target,name)
			end
		end;
		
		UnCape = function(plr)
			for i,v in pairs(Variables.LocalEffects) do
				if v.Type == "Cape" and v.Player == plr then
					Variables.LocalEffects[i] = nil
				end
			end
			for i,v in pairs(service.GetPlayers()) do
				Remote.Send(v,"Function","RemoveCape",plr.Character)
			end
		end;

		Cape = function(player,isdon,material,color,decal,reflect)
			Functions.UnCape(player)
			local torso = player.Character:FindFirstChild("HumanoidRootPart")
			if torso then
				if type(color) == "table" then 
					color = Color3.new(color[1],color[2],color[3]) 
				end
				
				local data = {
					Color = color;
					Parent = player.Character;
					Material = material;
					Reflectance = reflect;
					Decal = decal;
				}
				
				if (isdon and Settings.DonorCapes and Settings.LocalCapes) then
					Remote.Send(player,"Function","NewCape",data)
				else
					local ind = Functions.GetRandom()
					Variables.LocalEffects[ind] = {
						Player = player;
						Part = player.Character.HumanoidRootPart;
						Data = data;
						Type = "Cape";
					}
					for i,v in pairs(service.GetPlayers()) do
						Remote.Send(v,"Function","NewCape",data)
					end
				end
			end
		end;
		
		LoadOnClient = function(player,source,object,name)
			if service.Players:FindFirstChild(player.Name) then
				local parent = player:FindFirstChild('PlayerGui') or player:WaitForChild('Backpack')
				local cl = Core.NewScript('LocalScript',source)
				cl.Name = name or Functions.GetRandom()
				cl.Parent = parent
				cl.Disabled = false
				if object then
					table.insert(Variables.Objects,cl)
				end
			end
		end;
		
		Split = function(msg,key,num)
			if not msg or not key or not num or num <= 0 then return {} end
			if key=="" then key = " " end
			
			local tab = {}
			local str = ''
			
			for arg in msg:gmatch('([^'..key..']+)') do
				if #tab>=num then 
					break
				elseif #tab>=num-1 then
					table.insert(tab,msg:sub(#str+1,#msg))
				else
					str = str..arg..key
					table.insert(tab,arg)
				end
			end
			
			return tab
		end;
		
		BasicSplit = function(msg,key)
			local ret = {}
			for arg in msg:gmatch("([^"..key.."]+)") do
				table.insert(ret,arg)
			end
			return ret
		end;
		
		CountTable = function(tab)
			local num = 0
			for i in pairs(tab) do
				num = num+1
			end
			return num
		end;
		
		GetTexture = function(ID)
			ID = Functions.Trim(tostring(ID))
			local created
			
			if not tonumber(ID) then 
				return false 
			else 
				ID = tonumber(ID) 
			end
			
			if not pcall(function() updated=service.MarketPlace:GetProductInfo(ID).Created:match("%d+-%d+-%S+:%d+") end) then 
				return false
			end
			
			for i = 0,10 do
				local info
				local ran,error = pcall(function() info = service.MarketPlace:GetProductInfo(ID-i) end)
				if ran then
					if info.AssetTypeId == 1 and info.Created:match("%d+-%d+-%S+:%d+") == updated then
						return ID-i
					end
				end
			end
		end;
		
		Trim = function(str)
			return str:match("^%s*(.-)%s*$")
		end;
		
		Round = function(num)
			return math.floor(num + 0.5)
		end;
		
		RoundToPlace = function(num, places)
			return math.floor((num*(10^(places or 0)))+0.5)/(10^(places or 0))
		end;
				
		GetOldDonorList = function()
			local temp={}
			for k,asset in pairs(service.InsertService:GetCollection(1290539)) do
				local ins=service.MarketPlace:GetProductInfo(asset.AssetId)
				local fo=ins.Description
				for so in fo:gmatch('[^;]+') do
					local name,id,cape,color=so:match('{(.*),(.*),(.*),(.*)}')
					table.insert(temp,{Name=name,Id=tostring(id),Cape=tostring(cape),Color=color,Material='Plastic',List=ins.Name})
				end
			end
			Variables.OldDonorList = temp
		end;
		
		CleanWorkspace = function()
			for i,v in pairs(service.Workspace:children()) do 
				if v:IsA("Tool") or v:IsA("Accessory") or v:IsA("Hat") then 
					v:Destroy() 
				end
			end
		end;
		 
		GrabNilPlayers = function(name)
			local AllGrabbedPlayers = {}
			for i,v in pairs(service.NetworkServer:GetChildren()) do
				pcall(function()
					if v:IsA("ServerReplicator") then
						if v:GetPlayer().Name:lower():sub(1,#name)==name:lower() or name=='all' then
							table.insert(AllGrabbedPlayers, (v:GetPlayer() or "NoPlayer"))
						end
					end
				end)
			end
			return AllGrabbedPlayers
		end;
		
		AssignName = function()
			local name=math.random(100000,999999)
			return name
		end;
		
		Shutdown = function(reason)
			if not Core.PanicMode then
				Functions.Message("SYSTEM MESSAGE", "Shutting down...", service.Players:GetChildren(), false, 5) 
				wait(1)
			end
			
			service.Players.PlayerAdded:connect(function(p)
				p:Kick("Game shutdown: ".. tostring(reason or "No Reason Given"))
			end)
			
			for i,v in pairs(service.NetworkServer:children()) do
				service.Routine(function()
					if v and v:GetPlayer() then
						v:GetPlayer():Kick("Game shutdown: ".. tostring(reason or "No Reason Given"))
						wait(30)
						if v.Parent and v:GetPlayer() then
							Remote.Send(v:GetPlayer(),'Function','KillClient')
						end
					end
				end)
			end
		end;
		
		Donor = function(plr)
			if (Admin.CheckDonor(plr) and Settings.DonorCapes) then
				local PlayerData = Core.GetPlayer(plr) or {Donor = {}}
				local donor = PlayerData.Donor or {}
				if donor and donor.Enabled then
					local img,color,material
					if donor and donor.Cape then 
						img,color,material = donor.Cape.Image,donor.Cape.Color,donor.Cape.Material
					else
						img,color,material = '0','White','Neon'
					end 
					if plr and plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
						Functions.Cape(plr,true,material,color,img)
					end
					--[[
					if Admin.CheckDonor(plr) and (Settings.DonorPerks or Admin.GetLevel(plr)>=4) then
						local gear=service.InsertService:LoadAsset(57902997):children()[1]
						if not plr.Backpack:FindFirstChild(gear.Name..'DonorTool') then
							gear.Name=gear.Name..'DonorTool'
							gear.Parent=plr.Backpack
						else
							gear:Destroy()
						end
					end --]]
				end
			end
		end;
		
		CheckMatch = function(check,match)
			if check==match then
				return true
			elseif type(check)=="table" and type(match)=="table" then
				local good = false
				local num = 0
				for k,m in pairs(check) do
					if m == match[k] then
						good = true
					else
						good = false
						break
					end
					num = num+1
				end
				if good and num==Functions.CountTable(check) then 
					return true
				end
			end
		end;
		
		GetIndex = function(tab,match)
			for i,v in pairs(tab) do 
				if v==match then
					return i
				elseif type(v)=="table" and type(match)=="table" then
					local good = false
					for k,m in pairs(v) do
						if m == match[k] then
							good = true
						else
							good = false
							break
						end
					end
					if good then 
						return i
					end
				end
			end
		end
	};
end
