local T=script.Parent Create(T,{BackgroundColor3=GuiColor.Field;BorderColor3=GuiColor.Border,Active=true})local G=(T.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 o=(T.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 H=(T.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 y=(T.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 R=T.Parent:WaitForChild("\083\097\118\101\073\110\115\116\097\110\099\101")local f=T.Parent:WaitForChild("\067\111\110\102\105\114\109\097\116\105\111\110")local N=T.Parent:WaitForChild("\067\097\117\116\105\111\110")local j=T.Parent:WaitForChild("\084\097\098\108\101\067\097\117\116\105\111\110")local v=T.Parent:WaitForChild("\067\097\108\108\082\101\109\111\116\101")local V=T.Parent:WaitForChild("\083\099\114\105\112\116\069\100\105\116\111\114")local I=V:WaitForChild("\079\112\101\110\083\099\114\105\112\116")local z local w local P local C local a local U if saveinstance then U=true end if U then C=Instance.new("\070\111\108\100\101\114")C.Name="\068\101\120"a=Instance.new("\070\111\108\100\101\114",C)a.Name="\068\101\120\083\116\111\114\097\103\101"end local M local L local q if get_nil_instances and IfThisFunctionWasStableEnough then q=true end if q then M=Instance.new("\070\111\108\100\101\114")M.Name="\068\101\120 \073\110\116\101\114\110\097\108 \083\116\111\114\097\103\101"L=Instance.new("\070\111\108\100\101\114",M)L.Name="\078\105\108 \073\110\115\116\097\110\099\101\115"end local J=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=T})local E=ScrollBar(false)E.PageIncrement=1 Create(E.GUI,{Position=UDim2.new(1,-GUI_SIZE,0,HEADER_SIZE),Size=UDim2.new(0,GUI_SIZE,1,-HEADER_SIZE);Parent=T})local k=ScrollBar(true)k.PageIncrement=GUI_SIZE Create(k.GUI,{Position=UDim2.new(0,0,1,-GUI_SIZE),Size=UDim2.new(1,-GUI_SIZE,0,GUI_SIZE),Visible=false,Parent=T})local p=Create("\070\114\097\109\101",{Name="\072\101\097\100\101\114",BackgroundColor3=GuiColor.Background,BorderColor3=GuiColor.Border;Position=UDim2.new(0,0,0,0);Size=UDim2.new(1,0,0,HEADER_SIZE);Parent=T;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 h=Create("\084\101\120\116\066\111\120",{Text="\070\105\108\116\101\114 \087\111\114\107\115\112\097\099\101";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)})h.Parent=p SetZIndexOnChanged(T)local function d(T,G,o)return Color3.new(T/255,G/255,o/255)end local b={Font=Enum.Font.Arial,Margin=5,Black=d(0,0,0),White=d(255,255,255)}local A={Font=b.Font,FontSize=Enum.FontSize.Size14,TextColor=d(0,0,0),TextColorOver=b.White;TextXAlignment=Enum.TextXAlignment.Left;Height=20,BackColor=b.White;BackColorOver=d(86,125,188);BorderColor=d(216,216,216);BorderSizePixel=2,ArrowColor=d(160,160,160),ArrowColorOver=b.Black}local s={Font=b.Font;FontSize=Enum.FontSize.Size14,TextXAlignment=Enum.TextXAlignment.Left,TextColor=b.Black,TextColorOver=b.White,TextLockedColor=d(120,120,120);Height=24,BorderColor=d(216,216,216);BackgroundColor=b.White;BackgroundColorAlternate=d(246,246,246);BackgroundColorMouseover=d(211,224,244);TitleMarginLeft=15}local W local i local K local x function ClassCanCreate(T)local G,o=pcall(function()Instance.new(T)end)if o then return false else return true end end function GetClasses()if x==nil then return{}end local T={}for G,o in pairs(x.Classes)do if ClassCanCreate(o.Name)then table.insert(T,o.Name)end end return T end local function e(T,G)table.sort(T,function(T,o)return T[G]<o[G]end)end local function n(T)local G=T.tags for T,G in pairs(G)do if G=="\100\101\112\114\101\099\097\116\101\100"or G=="\104\105\100\100\101\110"or G=="\119\114\105\116\101\111\110\108\121"then return true end end return false end local function F(T)local G=x.Classes[T]local o={}if not G then return o end while G do if G.Name=="\073\110\115\116\097\110\099\101"then break end for T,G in pairs(G.Functions)do if not n(G)then table.insert(o,G)end end G=x.Classes[G.Superclass]end e(o,"\078\097\109\101")return o end function GetFunctions()if x==nil then return{}end local T=(SelectionVar()):Get()if#T==0 then return end local G=T[1]local o={}for T,G in pairs(F(G.ClassName))do table.insert(o,G)end return o end function CreateInsertObjectMenu(G,o,H,y)local R=game.Players.LocalPlayer:GetMouse()local f=T.Parent.AbsoluteSize.y if#G==0 then return end table.sort(G,function(T,G)return T<G end)local N=Instance.new("\070\114\097\109\101")N.Name="\073\110\115\101\114\116\079\098\106\101\099\116"N.Size=UDim2.new(0,200,1,0)N.BackgroundTransparency=1 N.Active=true local j=nil local v=nil local V=false local I=A.BorderSizePixel local function z()V=false if N then i.Visible=false end end local function w()V=true j=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")j.Size=UDim2.new(0,200,1,0)j.CanvasSize=UDim2.new(0,200,0,#G*A.Height)j.Position=UDim2.new(0,I,0,0)j.BackgroundTransparency=0 j.BackgroundColor3=A.BackColor j.BorderColor3=A.BorderColor j.BorderSizePixel=A.BorderSizePixel j.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"j.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"j.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"j.Active=true j.ZIndex=5 j.Parent=N local function T(T)y(T)z()end for G,o in pairs(G)do local H=CreateRightClickMenuItem(o,function()T(o)end,1)H.Size=UDim2.new(1,0,0,20)H.Position=UDim2.new(0,0,0,(G-1)*A.Height)H.ZIndex=j.ZIndex H.Parent=j end end w()return N end function CreateFunctionCallerMenu(G,o,H,y)local R=game.Players.LocalPlayer:GetMouse()local f=T.Parent.AbsoluteSize.y if#G==0 then return end table.sort(G,function(T,G)return T.Name<G.Name end)local N=Instance.new("\070\114\097\109\101")N.Name="\073\110\115\101\114\116\079\098\106\101\099\116"N.Size=UDim2.new(0,200,1,0)N.BackgroundTransparency=1 N.Active=true local j=nil local v=nil local V=false local I=A.BorderSizePixel local function z()V=false if N then i.Visible=false end end local function w()V=true j=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")j.Size=UDim2.new(0,300,1,0)j.CanvasSize=UDim2.new(0,300,0,#G*A.Height)j.Position=UDim2.new(0,I,0,0)j.BackgroundTransparency=0 j.BackgroundColor3=A.BackColor j.BorderColor3=A.BorderColor j.BorderSizePixel=A.BorderSizePixel j.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"j.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"j.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"j.Active=true j.ZIndex=5 j.Parent=N local function T(T)local G=""G=G.."\040"for o,H in pairs(T.Arguments)do G=G..(H.Type..(" "..H.Name))if o<#T.Arguments then G=G.."\044 "end end G=G.."\041"return G end local function o(T)y(T)z()end for G,H in pairs(G)do local y=CreateRightClickMenuItem(H.ReturnType..(" "..(H.Name..T(H))),function()o(H)end,2)y.Size=UDim2.new(1,0,0,20)y.Position=UDim2.new(0,0,0,(G-1)*A.Height)y.ZIndex=j.ZIndex y.Parent=j end end w()return N end function CreateInsertObject()if not i then return end i.Visible=true if W and i.Visible then i.Position=UDim2.new(0,(W.Position.X.Offset-W.Size.X.Offset)-2,0,0)end if i.Visible then i.Parent=T.Parent end end function CreateFunctionCaller()if K then K:Destroy()K=nil end K=CreateFunctionCallerMenu(GetFunctions(),"",false,function(T)K:Destroy()K=nil local G=(SelectionVar()):Get()for o=1,#G,1 do pcall(function()Instance.new(T,G[o])end)end print(T.Name.." \115\101\108\101\099\116\101\100 \116\111 \098\101 \099\097\108\108\101\100\046 \070\117\110\099\116\105\111\110 \099\097\108\108\101\114 \098\101\105\110\103 \097\100\100\101\100 \115\111\111\110\044 \112\108\101\097\115\101 \119\097\105\116\033")DestroyRightClick()end)if W and K then K.Position=UDim2.new(0,(W.Position.X.Offset-W.Size.X.Offset*1.5)-2,0,0)end if K then K.Parent=T.Parent end end function CreateRightClickMenuItem(T,G,o)local H=Instance.new("\084\101\120\116\066\117\116\116\111\110")H.Font=A.Font H.FontSize=A.FontSize H.TextColor3=A.TextColor H.TextXAlignment=A.TextXAlignment H.BackgroundColor3=A.BackColor H.AutoButtonColor=false H.BorderSizePixel=0 H.Active=true H.Text=T if o==1 then local G=Icon(nil,ExplorerIndex[T]or 0)G.Position=UDim2.new(0,0,0,2)G.Size=UDim2.new(0,16,0,16)G.IconMap.ZIndex=5 G.Parent=H H.Text="\t\t"..H.Text elseif o==2 then H.FontSize=Enum.FontSize.Size11 end H.MouseEnter:connect(function()H.TextColor3=A.TextColorOver H.BackgroundColor3=A.BackColorOver if not o and i then if i.Visible==false and H.Text=="\073\110\115\101\114\116 \079\098\106\101\099\116"then CreateInsertObject()elseif i.Visible and H.Text~="\073\110\115\101\114\116 \079\098\106\101\099\116"then i.Visible=false end end if not o then if K and H.Text~="\067\097\108\108 \070\117\110\099\116\105\111\110"then K:Destroy()K=nil elseif H.Text=="\067\097\108\108 \070\117\110\099\116\105\111\110"then CreateFunctionCaller()end end end)H.MouseLeave:connect(function()H.TextColor3=A.TextColor H.BackgroundColor3=A.BackColor end)H.MouseButton1Click:connect(function()H.TextColor3=A.TextColor H.BackgroundColor3=A.BackColor G(T)end)return H end function CreateRightClickMenu(T,G,o,H)local y=game.Players.LocalPlayer:GetMouse()local R=Instance.new("\070\114\097\109\101")R.Name="\068\114\111\112\068\111\119\110"R.Size=UDim2.new(0,200,1,0)R.BackgroundTransparency=1 R.Active=true local f=nil local N=nil local j=false local v=A.BorderSizePixel local function V()j=false if R then R:Destroy()DestroyRightClick()end end local function I()j=true f=Instance.new("\070\114\097\109\101")f.Size=UDim2.new(0,200,0,#T*A.Height)f.Position=UDim2.new(0,v,0,5)f.BackgroundTransparency=0 f.BackgroundColor3=A.BackColor f.BorderColor3=A.BorderColor f.BorderSizePixel=A.BorderSizePixel f.Active=true f.ZIndex=5 f.Parent=R local function G(T)H(T)V()end for T,o in pairs(T)do local H=CreateRightClickMenuItem(o,function()G(o)end)H.Size=UDim2.new(1,0,0,20)H.Position=UDim2.new(0,0,0,(T-1)*A.Height)H.ZIndex=f.ZIndex H.Parent=f end end I()return R end function checkMouseInGui(T)if T==nil then return false end local G=game.Players.LocalPlayer:GetMouse()local o=T.AbsolutePosition local H=T.AbsoluteSize if G.X>=o.x and(G.X<=o.x+H.x and(G.Y>=o.y and G.Y<=o.y+H.y))then return true else return false end end local c={}local function Y(T)T.Parent=nil end local Z do local G=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=T})function Z(T)G.Text=T return G.TextBounds.x end end local g=false


local explorerPanel = script.Parent
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 SaveInstanceWindow = explorerPanel.Parent:WaitForChild("SaveInstance")
local ConfirmationWindow = explorerPanel.Parent:WaitForChild("Confirmation")
local CautionWindow = explorerPanel.Parent:WaitForChild("Caution")
local TableCautionWindow = explorerPanel.Parent:WaitForChild("TableCaution")

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

local ScriptEditor = explorerPanel.Parent:WaitForChild("ScriptEditor")
local ScriptEditorEvent = ScriptEditor:WaitForChild("OpenScript")

local CurrentSaveInstanceWindow
local CurrentRemoteWindow

local lastSelectedNode

local DexStorage
local DexStorageMain
local DexStorageEnabled

if saveinstance then DexStorageEnabled = true end

if DexStorageEnabled then
	DexStorage = Instance.new("Folder")
	DexStorage.Name = "Dex"
	DexStorageMain = Instance.new("Folder",DexStorage)
	DexStorageMain.Name = "DexStorage"
end

local NilStorage
local NilStorageMain
local NilStorageEnabled

if get_nil_instances and IfThisFunctionWasStableEnough then NilStorageEnabled = true end

if NilStorageEnabled then
	NilStorage = Instance.new("Folder")
	NilStorage.Name = "Dex Internal Storage"
	NilStorageMain = Instance.new("Folder",NilStorage)
	NilStorageMain.Name = "Nil Instances"
end

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;
	BorderColor3 = GuiColor.Border;
	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',{
	Text = "Filter Workspace";
	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);
});
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 = CreateColor3(0,0,0);
	White = CreateColor3(255,255,255);
}

local DropDown = {
	Font = Styles.Font;
	FontSize = Enum.FontSize.Size14;
	TextColor = CreateColor3(0,0,0);
	TextColorOver = Styles.White;
	TextXAlignment = Enum.TextXAlignment.Left;
	Height = 20;
	BackColor = Styles.White;
	BackColorOver = CreateColor3(86,125,188);
	BorderColor = CreateColor3(216,216,216);
	BorderSizePixel = 2;
	ArrowColor = CreateColor3(160,160,160);
	ArrowColorOver = Styles.Black;
}

local Row = {
	Font = Styles.Font;
	FontSize = Enum.FontSize.Size14;
	TextXAlignment = Enum.TextXAlignment.Left;
	TextColor = Styles.Black;
	TextColorOver = Styles.White;
	TextLockedColor = CreateColor3(120,120,120);
	Height = 24;
	BorderColor = CreateColor3(216,216,216);
	BackgroundColor = Styles.White;
	BackgroundColorAlternate = CreateColor3(246,246,246);
	BackgroundColorMouseover = CreateColor3(211,224,244);
	TitleMarginLeft = 15;
}

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"]
	for _,name in pairs(tags) do
		if name == "deprecated"
			or name == "hidden"
			or name == "writeonly" then
			return true
		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.Functions) do
			if 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.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.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.Arguments) do
				paraString = paraString..v.Type.." "..v.Name
				if i < #functionData.Arguments 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..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-2,0,0)
	end
	if CurrentInsertObjectWindow.Visible then
		CurrentInsertObjectWindow.Parent = explorerPanel.Parent
	end
end

function CreateFunctionCaller()
	if CurrentFunctionCallerWindow then
		CurrentFunctionCallerWindow:Destroy()
		CurrentFunctionCallerWindow = nil
	end
	CurrentFunctionCallerWindow = CreateFunctionCallerMenu(
		GetFunctions(),
		"",
		false,
		function(option)
			CurrentFunctionCallerWindow:Destroy()
			CurrentFunctionCallerWindow = nil
			local list = SelectionVar():Get()
			for i = 1,#list do
				pcall(function() Instance.new(option,list[i]) end)
			end
			print(option.Name .. " selected to be called. Function caller being added soon, please wait!")
			--CallFunction()
			DestroyRightClick()
		end
	)
	if currentRightClickMenu and CurrentFunctionCallerWindow then
		CurrentFunctionCallerWindow.Position = UDim2.new(0,currentRightClickMenu.Position.X.Offset-currentRightClickMenu.Size.X.Offset*1.5-2,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.TextXAlignment = DropDown.TextXAlignment
	button.BackgroundColor3 = DropDown.BackColor
	button.AutoButtonColor = false
	button.BorderSizePixel = 0
	button.Active = true
	button.Text = text
	
	if insObj == 1 then
		local newIcon = Icon(nil,ExplorerIndex[text] or 0)
		newIcon.Position = UDim2.new(0,0,0,2)
		newIcon.Size = UDim2.new(0,16,0,16)
		newIcon.IconMap.ZIndex = 5
		newIcon.Parent = button
		button.Text = "\t\t"..button.Text
	elseif insObj == 2 then
		button.FontSize = Enum.FontSize.Size11
	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)	
	return button
end

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

	local frame = Instance.new("Frame")	
	frame.Name = "DropDown"
	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()
			DestroyRightClick()
		end
	end
	
	local function showMenu()
		expanded = true
		menu = Instance.new("Frame")
		menu.Size = UDim2.new(0, 200, 0, #choices * DropDown.Height)
		menu.Position = UDim2.new(0, margin, 0, 5)
		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 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)
			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 checkMouseInGui(gui)
	if gui == nil then return false end
	local plrMouse = game.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
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