Create(explorerPanel,{BackgroundColor3=GuiColor.Field,BorderColor3=GuiColor.Border,Active=true})local J=(explorerPanel.Parent:WaitForChild("\083\101\116\116\105\110\103\115\080\097\110\101\108")):WaitForChild("\071\101\116\083\101\116\116\105\110\103")local k=(explorerPanel.Parent:WaitForChild("\080\114\111\112\101\114\116\105\101\115\070\114\097\109\101")):WaitForChild("\071\101\116\065\112\105")local d=(explorerPanel.Parent:WaitForChild("\080\114\111\112\101\114\116\105\101\115\070\114\097\109\101")):WaitForChild("\071\101\116\065\119\097\105\116\105\110\103")local n=(explorerPanel.Parent:WaitForChild("\080\114\111\112\101\114\116\105\101\115\070\114\097\109\101")):WaitForChild("\083\101\116\065\119\097\105\116\105\110\103")local A=explorerPanel.Parent:WaitForChild("\067\097\117\116\105\111\110")local Q=explorerPanel.Parent:WaitForChild("\084\097\098\108\101\067\097\117\116\105\111\110")local u=explorerPanel.Parent:WaitForChild("\067\097\108\108\082\101\109\111\116\101")local C local D local U=Create("\070\114\097\109\101",{Name="\076\105\115\116";BackgroundTransparency=1;ClipsDescendants=true;Position=UDim2_new(0,0,0,HEADER_SIZE);Size=UDim2_new(1,-GUI_SIZE,1,-HEADER_SIZE),Parent=explorerPanel})local L=ScrollBar(false)L.PageIncrement=1 Create(L.GUI,{Position=UDim2_new(1,-GUI_SIZE,0,HEADER_SIZE),Size=UDim2_new(0,GUI_SIZE,1,-HEADER_SIZE);Parent=explorerPanel})local x=ScrollBar(true)x.PageIncrement=GUI_SIZE Create(x.GUI,{Position=UDim2_new(0,0,1,-GUI_SIZE),Size=UDim2_new(1,-GUI_SIZE,0,GUI_SIZE),Visible=false;Parent=explorerPanel})local M=Create("\070\114\097\109\101",{Name="\072\101\097\100\101\114";BackgroundColor3=GuiColor.Background;BorderSizePixel=0,Position=UDim2_new(0,0,0,0),Size=UDim2_new(1,0,0,HEADER_SIZE);Parent=explorerPanel;Create("\084\101\120\116\076\097\098\101\108",{Text="\069\120\112\108\111\114\101\114";BackgroundTransparency=1;TextColor3=GuiColor.Text;TextXAlignment="\076\101\102\116",Font=FONT,FontSize=FONT_SIZE;Position=UDim2_new(0,4,0,0);Size=UDim2_new(1,-4,.5,0)})})local r=Create("\084\101\120\116\066\111\120",{PlaceholderText="\070\105\108\116\101\114 \119\111\114\107\115\112\097\099\101\046\046\046",PlaceholderColor3=Color3_fromRGB(153,153,153);Text="";BackgroundTransparency=.8;TextColor3=GuiColor.Text,TextXAlignment="\076\101\102\116",Font=FONT;FontSize=FONT_SIZE,Position=UDim2_new(0,4,.5,0);Size=UDim2_new(1,-8,.5,-2);Create("\085\073\080\097\100\100\105\110\103",{PaddingLeft=UDim.new(0,4)})})r.Parent=M SetZIndexOnChanged(explorerPanel)local function w(J,k,d)return Color3_new(J/255,k/255,d/255)end local i={Font=Enum.Font.Arial,Margin=5,Black=Color3_fromRGB(0,0,5);Black2=Color3_fromRGB(24,24,29),White=Color3_fromRGB(244,244,249);WhiteOver=Color3_fromRGB(200,200,205);Hover=Color3_fromRGB(2,128,149),Hover2=Color3_fromRGB(5,102,146)}local a={Font=i.Font;FontSize=Enum.FontSize.Size14,TextXAlignment=Enum.TextXAlignment.Left;TextColor=i.White,TextColorOver=i.WhiteOver;TextLockedColor=Color3_fromRGB(155,155,160);Height=24;BorderColor=Color3_fromRGB(54,54,55),BackgroundColor=i.Black2,BackgroundColorAlternate=Color3_fromRGB(32,32,37),BackgroundColorMouseover=Color3_fromRGB(40,40,45),TitleMarginLeft=15}local T={Font=i.Font,FontSize=Enum.FontSize.Size14;TextColor=Color3_fromRGB(255,255,260);TextColorOver=a.TextColorOver,TextXAlignment=Enum.TextXAlignment.Left,Height=20,BackColor=i.Black2;BackColorOver=i.Hover2,BorderColor=Color3_fromRGB(45,45,50),BorderSizePixel=0;ArrowColor=Color3_fromRGB(80,80,83),ArrowColorOver=i.Hover}local B={BoxSize=13,BorderSizePixel=0,BorderColor=Color3_fromRGB(53,53,55);FrameColor=Color3_fromRGB(53,53,55),Size=20,Padding=4,ColorsPerRow=8,OuterBorder=1;OuterBorderColor=i.Black}local v local S local F local V function ClassCanCreate(J)local k,d=pcall(function()Instance_new(J)end)if d then return false else return true end end function GetClasses()if V==nil then return{}end local J={}for k,d in pairs(V.Classes)do if ClassCanCreate(d.Name)then table.insert(J,d.Name)end end return J end local function X(J,k)table.sort(J,function(J,d)return J[k]<d[k]end)end local function I(J)local k=J.Tags if k then for J,k in pairs(k)do if k=="\068\101\112\114\101\099\097\116\101\100"or k=="\072\105\100\100\101\110"or k=="\082\101\097\100\079\110\108\121"or k=="\078\111\116\083\099\114\105\112\116\097\098\108\101"then return true end end end return false end local function H(J)local k=V.Classes[J]local d={}if not k then return d end while k do if k.Name=="\073\110\115\116\097\110\099\101"then break end for J,k in pairs(k.Members)do if k.MemberType=="\070\117\110\099\116\105\111\110"and not I(k)then table.insert(d,k)end end k=V.Classes[k.Superclass]end X(d,"\078\097\109\101")return d end function GetFunctions()if V==nil then return{}end local J=(SelectionVar()):Get()if#J==0 then return end local k=J[1]local d={}for J,k in pairs(H(k.ClassName))do table.insert(d,k)end return d end function CreateInsertObjectMenu(J,k,d,n)local A=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer:GetMouse()local Q=explorerPanel.Parent.AbsoluteSize.y if#J==0 then return end table.sort(J,function(J,k)return J<k end)local u=Instance_new("\070\114\097\109\101")u.Name="\073\110\115\101\114\116\079\098\106\101\099\116"u.Size=UDim2_new(0,200,1,0)u.BackgroundTransparency=1 u.Active=true local C=nil local D=nil local U=false local L=T.BorderSizePixel local function x()U=false if u then S.Visible=false end end local function M()U=true C=Instance_new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")C.Size=UDim2_new(0,200,1,0)C.CanvasSize=UDim2_new(0,200,0,#J*T.Height)C.Position=UDim2_new(0,L,0,0)C.BackgroundTransparency=0 C.BackgroundColor3=T.BackColor C.BorderColor3=T.BorderColor C.BorderSizePixel=T.BorderSizePixel C.TopImage="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\098\108\097\099\107\066\107\103\095\115\113\117\097\114\101\046\112\110\103"C.MidImage="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\098\108\097\099\107\066\107\103\095\115\113\117\097\114\101\046\112\110\103"C.BottomImage="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\098\108\097\099\107\066\107\103\095\115\113\117\097\114\101\046\112\110\103"C.Active=true C.ZIndex=5 C.Parent=u local function k(J)n(J)x()end for J,d in pairs(J)do local n=CreateRightClickMenuItem(d,function()k(d)end,1)n.Size=UDim2_new(1,0,0,20)n.Position=UDim2_new(0,0,0,(J-1)*T.Height)n.ZIndex=C.ZIndex n.Parent=C end end M()return u end function CreateFunctionCallerMenu(J,k,d,n)local A=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer:GetMouse()local Q=explorerPanel.Parent.AbsoluteSize.y if#J==0 then return end table.sort(J,function(J,k)return J.Name<k.Name end)local u=Instance_new("\070\114\097\109\101")u.Name="\073\110\115\101\114\116\079\098\106\101\099\116"u.Size=UDim2_new(0,200,1,0)u.BackgroundTransparency=1 u.Active=true local C=nil local D=nil local U=false local L=T.BorderSizePixel local function x()U=false if u then S.Visible=false end end local function M()U=true C=Instance_new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")C.Size=UDim2_new(0,300,1,0)C.CanvasSize=UDim2_new(0,300,0,#J*T.Height)C.Position=UDim2_new(0,L,0,0)C.BackgroundTransparency=0 C.BackgroundColor3=T.BackColor C.BorderColor3=T.BorderColor C.BorderSizePixel=T.BorderSizePixel C.TopImage="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\098\108\097\099\107\066\107\103\095\115\113\117\097\114\101\046\112\110\103"C.MidImage="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\098\108\097\099\107\066\107\103\095\115\113\117\097\114\101\046\112\110\103"C.BottomImage="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\098\108\097\099\107\066\107\103\095\115\113\117\097\114\101\046\112\110\103"C.Active=true C.ZIndex=5 C.Parent=u local function k(J)local k=""k=k.."\040"for d,n in pairs(J.Parameters)do k=k..(n.Type.Name..(" "..n.Name))if d<#J.Parameters then k=k.."\044 "end end k=k.."\041"return k end local function d(J)n(J)x()end for J,n in pairs(J)do local A=CreateRightClickMenuItem(n.ReturnType.Name..(" "..(n.Name..k(n))),function()d(n)end,2)A.Size=UDim2_new(1,0,0,20)A.Position=UDim2_new(0,0,0,(J-1)*T.Height)A.ZIndex=C.ZIndex A.Parent=C end end M()return u end function CreateInsertObject()if not S then return end S.Visible=true if v and S.Visible then S.Position=UDim2_new(0,v.Position.X.Offset-v.Size.X.Offset,0,0)end if S.Visible then S.Parent=explorerPanel.Parent end end function CreateFunctionCaller(J)if F then F:Destroy()F=nil end F=CreateFunctionCallerMenu(GetFunctions(),"",false,function(J)F:Destroy()F=nil local k=(SelectionVar()):Get()for k,d in pairs(k)do local n=RemoteEvent:InvokeServer("\067\097\108\108\070\117\110\099\116\105\111\110",d,J.Name)print(n)pcall(function()print("\070\117\110\099\116\105\111\110",J.Name,"\111\110",d,"\058",unpack(n))end)end DestroyRightClick()end)if v and F then F.Position=UDim2_new(0,v.Position.X.Offset-v.Size.X.Offset*1.5,0,0)end if F then F.Parent=explorerPanel.Parent end end function CreateRightClickMenuItem(J,k,d)local n=Instance_new("\084\101\120\116\066\117\116\116\111\110")n.Font=T.Font n.FontSize=T.FontSize n.TextColor3=T.TextColor n.BackgroundColor3=T.BackColor n.AutoButtonColor=false n.BorderSizePixel=0 n.TextTransparency=1 n.Active=true if J then local A=Instance_new("\084\101\120\116\076\097\098\101\108")A.Size=UDim2_new(1,0,1,0)A.Font=T.Font A.FontSize=Enum.FontSize.Size11 A.TextColor3=T.TextColor A.TextXAlignment=T.TextXAlignment A.BackgroundTransparency=1 A.BorderSizePixel=0 A.ZIndex=5 A.Text=J n.Text=J A.Parent=n if d==2 then A.FontSize=Enum.FontSize.Size11 A.Size=UDim2_new(1,-16,1,0)A.Position=UDim2_new(0,16,0,0)else if d==1 or ExplorerIndex[J]then if ExplorerIndex[J]then local k=Icon(nil,ExplorerIndex[J]or 0)k.Position=UDim2_new(0,2,0,2)k.Size=UDim2_new(0,16,0,16)k.IconMap.ZIndex=5 k.Parent=n else local k=ClassIcon(nil,ClassIndex[J]or 0)k.Position=UDim2_new(0,2,0,2)k.Size=UDim2_new(0,16,0,16)k.IconMap.ZIndex=5 k.Parent=n end end A.Size=UDim2_new(1,-32,1,0)A.Position=UDim2_new(0,32,0,0)end n.MouseEnter:connect(function()n.TextColor3=T.TextColorOver n.BackgroundColor3=T.BackColorOver if not d and S then if S.Visible==false and n.Text=="\073\110\115\101\114\116 \079\098\106\101\099\116"then CreateInsertObject()elseif S.Visible and n.Text~="\073\110\115\101\114\116 \079\098\106\101\099\116"then S.Visible=false end end if not d then if F and n.Text~="\067\097\108\108 \070\117\110\099\116\105\111\110"then F:Destroy()F=nil elseif n.Text=="\067\097\108\108 \070\117\110\099\116\105\111\110"then CreateFunctionCaller()end end end)n.MouseLeave:connect(function()n.TextColor3=T.TextColor n.BackgroundColor3=T.BackColor end)n.MouseButton1Click:connect(function()n.TextColor3=T.TextColor n.BackgroundColor3=T.BackColor k(J)end)else local J=Instance_new("\070\114\097\109\101",n)J.Size=UDim2_new(1,-20,0,1)J.Position=UDim2_new(0,16,0,2)J.BackgroundColor3=T.BorderColor J.BorderSizePixel=0 J.ZIndex=5 end return n end function CreateRightClickMenu(J,k,d,n)local A=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer:GetMouse()local Q=Instance_new("\084\101\120\116\066\117\116\116\111\110")Q.Name="\068\114\111\112\068\111\119\110"Q.Size=UDim2_new(0,200,0,0)Q.BackgroundTransparency=1 Q.AutoButtonColor=false Q.Active=false local u=nil local C=nil local D=false local U=T.BorderSizePixel local function L()D=false if Q then Q:Destroy()DestroyRightClick()end end local function x()D=true u=Instance_new("\070\114\097\109\101")u.Size=UDim2_new(0,200,0,0)for J,k in pairs(J)do if k then u.Size=u.Size+UDim2_new(0,0,0,20)else u.Size=u.Size+UDim2_new(0,0,0,7)end end Q.Size=u.Size+UDim2_new(0,0,0,6)u.Position=UDim2_new(0,0,0,0)u.BackgroundTransparency=0 u.BackgroundColor3=T.BackColor u.BorderColor3=T.BorderColor u.BorderSizePixel=T.BorderSizePixel u.Active=true u.ZIndex=5 u.Parent=Q local function k(J)n(J)L()end local d for J,n in pairs(J)do local A=CreateRightClickMenuItem(n,function()k(n)end)if n then A.Size=UDim2_new(1,0,0,20)else A.Size=UDim2_new(1,0,0,7)end if d then A.Position=UDim2_new(0,0,0,d.Position.Height.Offset+d.Size.Height.Offset)end A.ZIndex=u.ZIndex A.Parent=u d=A end end x()return Q end function checkMouseInGui(J)if J==nil then return false end local k=(game:GetService("\080\108\097\121\101\114\115")).LocalPlayer:GetMouse()local d=J.AbsolutePosition local n=J.AbsoluteSize if k.X>=d.x and(k.X<=d.x+n.x and(k.Y>=d.y and k.Y<=d.y+n.y))then return true else return false end end local N={}local function g(J)J.Parent=nil RemoteEvent:InvokeServer("\068\101\108\101\116\101",J)end local m do local J=Create("\084\101\120\116\076\097\098\101\108",{Name="\084\101\120\116\087\105\100\116\104",TextXAlignment="\076\101\102\116",TextYAlignment="\067\101\110\116\101\114",Font=FONT;FontSize=FONT_SIZE,Text="";Position=UDim2_new(0,0,0,0),Size=UDim2_new(1,0,1,0),Visible=false;Parent=explorerPanel})function m(k)J.Text=k return J.TextBounds.x end end local O=false


Create(explorerPanel,{
	BackgroundColor3 = GuiColor.Field;
	BorderColor3 = GuiColor.Border;
	Active = true;
})

local SettingsRemote = explorerPanel.Parent:WaitForChild("SettingsPanel"):WaitForChild("GetSetting")
local GetApiRemote = explorerPanel.Parent:WaitForChild("PropertiesFrame"):WaitForChild("GetApi")
local GetAwaitRemote = explorerPanel.Parent:WaitForChild("PropertiesFrame"):WaitForChild("GetAwaiting")
local bindSetAwaiting = explorerPanel.Parent:WaitForChild("PropertiesFrame"):WaitForChild("SetAwaiting")

local CautionWindow = explorerPanel.Parent:WaitForChild("Caution")
local TableCautionWindow = explorerPanel.Parent:WaitForChild("TableCaution")

local RemoteWindow = explorerPanel.Parent:WaitForChild("CallRemote")

local CurrentRemoteWindow

local lastSelectedNode

local listFrame = Create('Frame',{
	Name = "List";
	BackgroundTransparency = 1;
	ClipsDescendants = true;
	Position = UDim2_new(0,0,0,HEADER_SIZE);
	Size = UDim2_new(1,-GUI_SIZE,1,-HEADER_SIZE);
	Parent = explorerPanel;
})

local scrollBar = ScrollBar(false)
scrollBar.PageIncrement = 1
Create(scrollBar.GUI,{
	Position = UDim2_new(1,-GUI_SIZE,0,HEADER_SIZE);
	Size = UDim2_new(0,GUI_SIZE,1,-HEADER_SIZE);
	Parent = explorerPanel;
})

local scrollBarH = ScrollBar(true)
scrollBarH.PageIncrement = GUI_SIZE
Create(scrollBarH.GUI,{
	Position = UDim2_new(0,0,1,-GUI_SIZE);
	Size = UDim2_new(1,-GUI_SIZE,0,GUI_SIZE);
	Visible = false;
	Parent = explorerPanel;
})

local headerFrame = Create('Frame',{
	Name = "Header";
	BackgroundColor3 = GuiColor.Background;
	BorderSizePixel = 0;
	Position = UDim2_new(0,0,0,0);
	Size = UDim2_new(1,0,0,HEADER_SIZE);
	Parent = explorerPanel;
	Create('TextLabel',{
		Text = "Explorer";
		BackgroundTransparency = 1;
		TextColor3 = GuiColor.Text;
		TextXAlignment = 'Left';
		Font = FONT;
		FontSize = FONT_SIZE;
		Position = UDim2_new(0,4,0,0);
		Size = UDim2_new(1,-4,0.5,0);
	});
})

local explorerFilter = 	Create('TextBox',{
	PlaceholderText = "Filter workspace...";
	PlaceholderColor3 = Color3_fromRGB(153, 153, 153);
	Text = "";
	BackgroundTransparency = 0.8;
	TextColor3 = GuiColor.Text;
	TextXAlignment = 'Left';
	Font = FONT;
	FontSize = FONT_SIZE;
	Position = UDim2_new(0,4,0.5,0);
	Size = UDim2_new(1,-8,0.5,-2);
	Create('UIPadding',{
		PaddingLeft = UDim.new(0, 4)
	})
});
explorerFilter.Parent = headerFrame

SetZIndexOnChanged(explorerPanel)

local function CreateColor3(r, g, b) return Color3_new(r/255,g/255,b/255) end

local Styles = {
	Font = Enum.Font.Arial,
	Margin = 5,
	Black = Color3_fromRGB(0,0,5),
	Black2 = Color3_fromRGB(24, 24, 29),
	White = Color3_fromRGB(244,244,249),
	WhiteOver = Color3_fromRGB(200,200,205),
	Hover = Color3_fromRGB(2, 128, 149),
	Hover2 = Color3_fromRGB(5, 102, 146)
}

local Row = {
	Font = Styles.Font,
	FontSize = Enum.FontSize.Size14,
	TextXAlignment = Enum.TextXAlignment.Left,
	TextColor = Styles.White,
	TextColorOver = Styles.WhiteOver,
	TextLockedColor = Color3_fromRGB(155,155,160),
	Height = 24,
	BorderColor = Color3_fromRGB(54,54,55),
	BackgroundColor = Styles.Black2,
	BackgroundColorAlternate = Color3_fromRGB(32, 32, 37),
	BackgroundColorMouseover = Color3_fromRGB(40, 40, 45),
	TitleMarginLeft = 15
}

local DropDown = {
	Font = Styles.Font,
	FontSize = Enum.FontSize.Size14,
	TextColor = Color3_fromRGB(255,255,260),
	TextColorOver = Row.TextColorOver,
	TextXAlignment = Enum.TextXAlignment.Left,
	Height = 20,
	BackColor = Styles.Black2,
	BackColorOver = Styles.Hover2,
	BorderColor = Color3_fromRGB(45,45,50),
	BorderSizePixel = 0,
	ArrowColor = Color3_fromRGB(80,80,83),
	ArrowColorOver = Styles.Hover
}

local BrickColors = {
	BoxSize = 13,
	BorderSizePixel = 0,
	BorderColor = Color3_fromRGB(53,53,55),
	FrameColor = Color3_fromRGB(53,53,55),
	Size = 20,
	Padding = 4,
	ColorsPerRow = 8,
	OuterBorder = 1,
	OuterBorderColor = Styles.Black
}

local currentRightClickMenu
local CurrentInsertObjectWindow
local CurrentFunctionCallerWindow

local RbxApi

function ClassCanCreate(IName)
	local success,err = pcall(function() Instance_new(IName) end)
	if err then
		return false
	else
		return true
	end
end

function GetClasses()
	if RbxApi == nil then return {} end
	local classTable = {}
	for i,v in pairs(RbxApi.Classes) do
		if ClassCanCreate(v.Name) then
			table.insert(classTable,v.Name)
		end
	end
	return classTable
end

local function sortAlphabetic(t, property)
	table.sort(t,
		function(x,y) return x[property] < y[property]
		end)
end

local function FunctionIsHidden(functionData)
	local tags = functionData["Tags"]
	if tags then
		for _,name in pairs(tags) do
			if name == "Deprecated"
				or name == "Hidden"
				or name == "ReadOnly"
				or name == "NotScriptable" then
				return true
			end
		end
	end
	return false
end

local function GetAllFunctions(className)
	local class = RbxApi.Classes[className]
	local functions = {}

	if not class then return functions end

	while class do
		if class.Name == "Instance" then break end
		for _,nextFunction in pairs(class.Members) do
			if nextFunction.MemberType == "Function" and not FunctionIsHidden(nextFunction) then
				table.insert(functions, nextFunction)
			end
		end
		class = RbxApi.Classes[class.Superclass]
	end

	sortAlphabetic(functions, "Name")

	return functions
end

function GetFunctions()
	if RbxApi == nil then return {} end
	local List = SelectionVar():Get()

	if #List == 0 then return end

	local MyObject = List[1]

	local functionTable = {}
	for i,v in pairs(GetAllFunctions(MyObject.ClassName)) do
		table.insert(functionTable,v)
	end
	return functionTable
end

function CreateInsertObjectMenu(choices, currentChoice, readOnly, onClick)
	local mouse = game:GetService("Players").LocalPlayer:GetMouse()
	local totalSize = explorerPanel.Parent.AbsoluteSize.y
	if #choices == 0 then return end

	table.sort(choices, function(a,b) return a < b end)

	local frame = Instance_new("Frame")	
	frame.Name = "InsertObject"
	frame.Size = UDim2_new(0, 200, 1, 0)
	frame.BackgroundTransparency = 1
	frame.Active = true

	local menu = nil
	local arrow = nil
	local expanded = false
	local margin = DropDown.BorderSizePixel;

	--[[
	local button = Instance_new("TextButton")
	button.Font = Row.Font
	button.FontSize = Row.FontSize
	button.TextXAlignment = Row.TextXAlignment
	button.BackgroundTransparency = 1
	button.TextColor3 = Row.TextColor
	if readOnly then
		button.TextColor3 = Row.TextLockedColor
	end
	button.Text = currentChoice
	button.Size = UDim2_new(1, -2 * Styles.Margin, 1, 0)
	button.Position = UDim2_new(0, Styles.Margin, 0, 0)
	button.Parent = frame
	--]]

	local function hideMenu()
		expanded = false
		--showArrow(DropDown.ArrowColor)
		if frame then
			--frame:Destroy()
			CurrentInsertObjectWindow.Visible = false
		end
	end

	local function showMenu()
		expanded = true
		menu = Instance_new("ScrollingFrame")
		menu.Size = UDim2_new(0,200,1,0)
		menu.CanvasSize = UDim2_new(0, 200, 0, #choices * DropDown.Height)
		menu.Position = UDim2_new(0, margin, 0, 0)
		menu.BackgroundTransparency = 0
		menu.BackgroundColor3 = DropDown.BackColor
		menu.BorderColor3 = DropDown.BorderColor
		menu.BorderSizePixel = DropDown.BorderSizePixel
		menu.TopImage = "rbxasset://textures/blackBkg_square.png"
		menu.MidImage = "rbxasset://textures/blackBkg_square.png"
		menu.BottomImage = "rbxasset://textures/blackBkg_square.png"
		menu.Active = true
		menu.ZIndex = 5
		menu.Parent = frame

		--local parentFrameHeight = script.Parent.List.Size.Y.Offset
		--local rowHeight = mouse.Y
		--if (rowHeight + menu.Size.Y.Offset) > parentFrameHeight then
		--	menu.Position = UDim2_new(0, margin, 0, -1 * (#choices * DropDown.Height) - margin)
		--end

		local function choice(name)
			onClick(name)
			hideMenu()
		end

		for i,name in pairs(choices) do
			local option = CreateRightClickMenuItem(name, function()
				choice(name)
			end,1)
			option.Size = UDim2_new(1, 0, 0, 20)
			option.Position = UDim2_new(0, 0, 0, (i - 1) * DropDown.Height)
			option.ZIndex = menu.ZIndex
			option.Parent = menu
		end
	end

	showMenu()

	return frame
end

function CreateFunctionCallerMenu(choices, currentChoice, readOnly, onClick)
	local mouse = game:GetService("Players").LocalPlayer:GetMouse()
	local totalSize = explorerPanel.Parent.AbsoluteSize.y
	if #choices == 0 then return end

	table.sort(choices, function(a,b) return a.Name < b.Name end)

	local frame = Instance_new("Frame")	
	frame.Name = "InsertObject"
	frame.Size = UDim2_new(0, 200, 1, 0)
	frame.BackgroundTransparency = 1
	frame.Active = true

	local menu = nil
	local arrow = nil
	local expanded = false
	local margin = DropDown.BorderSizePixel;

	local function hideMenu()
		expanded = false
		--showArrow(DropDown.ArrowColor)
		if frame then
			--frame:Destroy()
			CurrentInsertObjectWindow.Visible = false
		end
	end

	local function showMenu()
		expanded = true
		menu = Instance_new("ScrollingFrame")
		menu.Size = UDim2_new(0,300,1,0)
		menu.CanvasSize = UDim2_new(0, 300, 0, #choices * DropDown.Height)
		menu.Position = UDim2_new(0, margin, 0, 0)
		menu.BackgroundTransparency = 0
		menu.BackgroundColor3 = DropDown.BackColor
		menu.BorderColor3 = DropDown.BorderColor
		menu.BorderSizePixel = DropDown.BorderSizePixel
		menu.TopImage = "rbxasset://textures/blackBkg_square.png"
		menu.MidImage = "rbxasset://textures/blackBkg_square.png"
		menu.BottomImage = "rbxasset://textures/blackBkg_square.png"
		menu.Active = true
		menu.ZIndex = 5
		menu.Parent = frame

		--local parentFrameHeight = script.Parent.List.Size.Y.Offset
		--local rowHeight = mouse.Y
		--if (rowHeight + menu.Size.Y.Offset) > parentFrameHeight then
		--	menu.Position = UDim2_new(0, margin, 0, -1 * (#choices * DropDown.Height) - margin)
		--end

		local function GetParameters(functionData)
			local paraString = ""
			paraString = paraString.."("
			for i,v in pairs(functionData.Parameters) do
				paraString = paraString..v.Type.Name.." "..v.Name
				if i < #functionData.Parameters then
					paraString = paraString..", "
				end
			end
			paraString = paraString..")"
			return paraString
		end

		local function choice(name)
			onClick(name)
			hideMenu()
		end

		for i,name in pairs(choices) do
			local option = CreateRightClickMenuItem(name.ReturnType.Name.." "..name.Name..GetParameters(name), function()
				choice(name)
			end,2)
			option.Size = UDim2_new(1, 0, 0, 20)
			option.Position = UDim2_new(0, 0, 0, (i - 1) * DropDown.Height)
			option.ZIndex = menu.ZIndex
			option.Parent = menu
		end
	end


	showMenu()


	return frame
end

function CreateInsertObject()
	if not CurrentInsertObjectWindow then return end
	CurrentInsertObjectWindow.Visible = true
	if currentRightClickMenu and CurrentInsertObjectWindow.Visible then
		CurrentInsertObjectWindow.Position = UDim2_new(0,currentRightClickMenu.Position.X.Offset-currentRightClickMenu.Size.X.Offset,0,0)
	end
	if CurrentInsertObjectWindow.Visible then
		CurrentInsertObjectWindow.Parent = explorerPanel.Parent
	end
end

function CreateFunctionCaller(oh)
	if CurrentFunctionCallerWindow then
		CurrentFunctionCallerWindow:Destroy()
		CurrentFunctionCallerWindow = nil
	end
	CurrentFunctionCallerWindow = CreateFunctionCallerMenu(
		GetFunctions(),
		"",
		false,
		function(option)
			CurrentFunctionCallerWindow:Destroy()
			CurrentFunctionCallerWindow = nil
			local list = SelectionVar():Get()
			for i,v in pairs(list) do
				local rets = RemoteEvent:InvokeServer("CallFunction",v,option.Name)
				print(rets)
				pcall(function() print("Function", option.Name, "on", v, ":", unpack(rets)) end)
			end

			DestroyRightClick()
		end
	)
	if currentRightClickMenu and CurrentFunctionCallerWindow then
		CurrentFunctionCallerWindow.Position = UDim2_new(0,currentRightClickMenu.Position.X.Offset-currentRightClickMenu.Size.X.Offset*1.5,0,0)
	end
	if CurrentFunctionCallerWindow then
		CurrentFunctionCallerWindow.Parent = explorerPanel.Parent
	end
end

function CreateRightClickMenuItem(text, onClick, insObj)
	local button = Instance_new("TextButton")
	button.Font = DropDown.Font
	button.FontSize = DropDown.FontSize
	button.TextColor3 = DropDown.TextColor
	button.BackgroundColor3 = DropDown.BackColor
	button.AutoButtonColor = false
	button.BorderSizePixel = 0
	button.TextTransparency = 1
	button.Active = true

	if text then
		local label = Instance_new("TextLabel")
		label.Size = UDim2_new(1, 0, 1, 0)
		label.Font = DropDown.Font
		label.FontSize = Enum.FontSize.Size11
		label.TextColor3 = DropDown.TextColor
		label.TextXAlignment = DropDown.TextXAlignment
		label.BackgroundTransparency = 1
		label.BorderSizePixel = 0
		label.ZIndex = 5

		label.Text = text
		button.Text = text

		label.Parent = button


		if insObj == 2 then
			label.FontSize = Enum.FontSize.Size11
			label.Size = UDim2_new(1, -16, 1, 0)
			label.Position = UDim2_new(0, 16, 0, 0)
		else
			if insObj == 1 or ExplorerIndex[text] then
				if ExplorerIndex[text] then
					local newIcon = Icon(nil,ExplorerIndex[text] or 0)
					newIcon.Position = UDim2_new(0,2,0,2)
					newIcon.Size = UDim2_new(0,16,0,16)
					newIcon.IconMap.ZIndex = 5
					newIcon.Parent = button
				else
					local newIcon = ClassIcon(nil,ClassIndex[text] or 0)
					newIcon.Position = UDim2_new(0,2,0,2)
					newIcon.Size = UDim2_new(0,16,0,16)
					newIcon.IconMap.ZIndex = 5
					newIcon.Parent = button
				end
			end

			label.Size = UDim2_new(1, -32, 1, 0)
			label.Position = UDim2_new(0, 32, 0, 0)
		end


		button.MouseEnter:connect(function()
			button.TextColor3 = DropDown.TextColorOver
			button.BackgroundColor3 = DropDown.BackColorOver
			if not insObj and CurrentInsertObjectWindow then
				if CurrentInsertObjectWindow.Visible == false and button.Text == "Insert Object" then
					CreateInsertObject()
				elseif CurrentInsertObjectWindow.Visible and button.Text ~= "Insert Object" then
					CurrentInsertObjectWindow.Visible = false
				end
			end
			if not insObj then
				if CurrentFunctionCallerWindow and button.Text ~= "Call Function" then
					CurrentFunctionCallerWindow:Destroy()
					CurrentFunctionCallerWindow = nil
				elseif button.Text == "Call Function" then
					CreateFunctionCaller()
				end
			end
		end)
		button.MouseLeave:connect(function()
			button.TextColor3 = DropDown.TextColor
			button.BackgroundColor3 = DropDown.BackColor
		end)
		button.MouseButton1Click:connect(function()
			button.TextColor3 = DropDown.TextColor
			button.BackgroundColor3 = DropDown.BackColor
			onClick(text)
		end)	
	else
		local sep = Instance_new("Frame", button)
		sep.Size = UDim2_new(1, -20, 0, 1)
		sep.Position = UDim2_new(0, 16, 0, 2)
		sep.BackgroundColor3 = DropDown.BorderColor
		sep.BorderSizePixel = 0
		sep.ZIndex = 5
	end

	return button
end

function CreateRightClickMenu(choices, currentChoice, readOnly, onClick)
	local mouse = game:GetService("Players").LocalPlayer:GetMouse()

	local frame = Instance_new("TextButton")	
	frame.Name = "DropDown"
	frame.Size = UDim2_new(0, 200, 0, 0)
	frame.BackgroundTransparency = 1
	frame.AutoButtonColor = false
	frame.Active = false

	local menu = nil
	local arrow = nil
	local expanded = false
	local margin = DropDown.BorderSizePixel;

	local function hideMenu()
		expanded = false
		if frame then
			frame:Destroy()
			DestroyRightClick()
		end
	end

	local function showMenu()
		expanded = true
		menu = Instance_new("Frame")
		menu.Size = UDim2_new(0, 200, 0, 0)

		for i,name in pairs(choices) do
			if name then
				menu.Size = menu.Size + UDim2_new(0, 0, 0, 20)
			else
				menu.Size = menu.Size + UDim2_new(0, 0, 0, 7)
			end		
		end

		frame.Size = menu.Size + UDim2_new(0, 0, 0, 6)

		menu.Position = UDim2_new(0, 0, 0, 0)
		menu.BackgroundTransparency = 0
		menu.BackgroundColor3 = DropDown.BackColor
		menu.BorderColor3 = DropDown.BorderColor
		menu.BorderSizePixel = DropDown.BorderSizePixel
		menu.Active = true
		menu.ZIndex = 5
		menu.Parent = frame

		local function choice(name)
			onClick(name)
			hideMenu()
		end

		local previous		
		for i,name in pairs(choices) do
			local option = CreateRightClickMenuItem(name, function()
				choice(name)
			end)

			if name then
				option.Size = UDim2_new(1, 0, 0, 20)
			else
				option.Size = UDim2_new(1, 0, 0, 7)
			end

			if previous then
				option.Position = UDim2_new(0, 0, 0, previous.Position.Height.Offset + previous.Size.Height.Offset)
			end

			option.ZIndex = menu.ZIndex
			option.Parent = menu

			previous = option			
		end
	end

	showMenu()

	return frame
end

function checkMouseInGui(gui)
	if gui == nil then return false end
	local plrMouse = game:GetService("Players").LocalPlayer:GetMouse()
	local guiPosition = gui.AbsolutePosition
	local guiSize = gui.AbsoluteSize	

	if plrMouse.X >= guiPosition.x and plrMouse.X <= guiPosition.x + guiSize.x and plrMouse.Y >= guiPosition.y and plrMouse.Y <= guiPosition.y + guiSize.y then
		return true
	else
		return false
	end
end

local clipboard = {}
local function delete(o)
	o.Parent = nil
	RemoteEvent:InvokeServer("Delete", o)
end

local getTextWidth do
	local text = Create('TextLabel',{
		Name = "TextWidth";
		TextXAlignment = 'Left';
		TextYAlignment = 'Center';
		Font = FONT;
		FontSize = FONT_SIZE;
		Text = "";
		Position = UDim2_new(0,0,0,0);
		Size = UDim2_new(1,0,1,0);
		Visible = false;
		Parent = explorerPanel;
	})
	function getTextWidth(s)
		text.Text = s
		return text.TextBounds.x
	end
end

local nameScanned = false