Tools.NewPart.Listeners.Equipped=function()local M=Tools.NewPart M.State.PreviousSelectionBoxColor=SelectionBoxColor SelectionBoxColor=M.Color updateSelectionBoxColor()M:showGUI()M:changeType(M.Options.type)end Tools.NewPart.Listeners.Unequipped=function()local M=Tools.NewPart M:hideGUI()for L,o in pairs(M.Connections)do o:disconnect()M.Connections[L]=nil end SelectionBoxColor=M.State.PreviousSelectionBoxColor updateSelectionBoxColor()end Tools.NewPart.Listeners.Button1Down=function()local M=Tools.NewPart local L if M.Options.type=="\110\111\114\109\097\108"then L=Instance.new("\080\097\114\116",Services.Workspace)L.FormFactor="\067\117\115\116\111\109"L.Size=Vector3.new(4,1,2)elseif M.Options.type=="\116\114\117\115\115"then L=Instance.new("\084\114\117\115\115\080\097\114\116",Services.Workspace)elseif M.Options.type=="\119\101\100\103\101"then L=Instance.new("\087\101\100\103\101\080\097\114\116",Services.Workspace)elseif M.Options.type=="\099\111\114\110\101\114"then L=Instance.new("\067\111\114\110\101\114\087\101\100\103\101\080\097\114\116",Services.Workspace)elseif M.Options.type=="\099\121\108\105\110\100\101\114"then L=Instance.new("\080\097\114\116",Services.Workspace)L.Shape="\067\121\108\105\110\100\101\114"elseif M.Options.type=="\098\097\108\108"then L=Instance.new("\080\097\114\116",Services.Workspace)L.Shape="\066\097\108\108"elseif M.Options.type=="\115\101\097\116"then L=Instance.new("\083\101\097\116",Services.Workspace)elseif M.Options.type=="\118\101\104\105\099\108\101 \115\101\097\116"then L=Instance.new("\086\101\104\105\099\108\101\083\101\097\116",Services.Workspace)elseif M.Options.type=="\115\112\097\119\110"then L=Instance.new("\083\112\097\119\110\076\111\099\097\116\105\111\110",Services.Workspace)end L.Anchored=true Selection:clear()Selection:add(L)local o={target=L;apply=function(M)Selection:clear()if M.target then M.target.Parent=Services.Workspace Selection:add(M.target)end end,unapply=function(M)if M.target then M.target.Parent=nil end end}History:add(o)equipTool(Tools.Move)Tools.Move.ManualTarget=L L.CFrame=CFrame.new(Mouse.Hit.p)Tools.Move.Listeners.Button1Down()Tools.Move.Listeners.Move()end Tools.NewPart.changeType=function(M,L)M.Options.type=L M.TypeDropdown:selectOption(L:upper())if M.TypeDropdown.open then M.TypeDropdown:toggle()end end Tools.NewPart.showGUI=function(M)if not M.GUI then local L=Tool.Interfaces.BTNewPartToolGUI:Clone()L.Parent=UI local o=createDropdown()M.TypeDropdown=o o.Frame.Parent=L.TypeOption o.Frame.Position=UDim2.new(0,70,0,0)o.Frame.Size=UDim2.new(0,140,0,25);(o:addOption("\078\079\082\077\065\076")).MouseButton1Up:connect(function()M:changeType("\110\111\114\109\097\108")end);(o:addOption("\084\082\085\083\083")).MouseButton1Up:connect(function()M:changeType("\116\114\117\115\115")end);(o:addOption("\087\069\068\071\069")).MouseButton1Up:connect(function()M:changeType("\119\101\100\103\101")end);(o:addOption("\067\079\082\078\069\082")).MouseButton1Up:connect(function()M:changeType("\099\111\114\110\101\114")end);(o:addOption("\067\089\076\073\078\068\069\082")).MouseButton1Up:connect(function()M:changeType("\099\121\108\105\110\100\101\114")end);(o:addOption("\066\065\076\076")).MouseButton1Up:connect(function()M:changeType("\098\097\108\108")end);(o:addOption("\083\069\065\084")).MouseButton1Up:connect(function()M:changeType("\115\101\097\116")end);(o:addOption("\086\069\072\073\067\076\069 \083\069\065\084")).MouseButton1Up:connect(function()M:changeType("\118\101\104\105\099\108\101 \115\101\097\116")end);(o:addOption("\083\080\065\087\078")).MouseButton1Up:connect(function()M:changeType("\115\112\097\119\110")end)M.GUI=L end M.GUI.Visible=true end Tools.NewPart.hideGUI=function(M)if M.GUI then M.GUI.Visible=false end end Tools.NewPart.Loaded=true
-- Start adding functionality to the tool
Tools.NewPart.Listeners.Equipped = function()
	local self = Tools.NewPart

	-- Change the color of selection boxes temporarily
	self.State.PreviousSelectionBoxColor = SelectionBoxColor
	SelectionBoxColor = self.Color
	updateSelectionBoxColor()

	-- Reveal the GUI
	self:showGUI()

	-- Restore the type option
	self:changeType(self.Options.type)
end

Tools.NewPart.Listeners.Unequipped = function()
	local self = Tools.NewPart

	-- Hide the GUI
	self:hideGUI()

	-- Disconnect temporary connections
	for connection_index, Connection in pairs(self.Connections) do
		Connection:disconnect()
		self.Connections[connection_index] = nil
	end

	-- Restore the original color of selection boxes
	SelectionBoxColor = self.State.PreviousSelectionBoxColor
	updateSelectionBoxColor()
end

Tools.NewPart.Listeners.Button1Down = function()
	local self = Tools.NewPart

	local NewPart

	-- Create the new part of type `self.Options.type`
	if self.Options.type == "normal" then
		NewPart = Instance.new("Part", Services.Workspace)
		NewPart.FormFactor = "Custom"
		NewPart.Size = Vector3.new(4, 1, 2)
	elseif self.Options.type == "truss" then
		NewPart = Instance.new("TrussPart", Services.Workspace)
	elseif self.Options.type == "wedge" then
		NewPart = Instance.new("WedgePart", Services.Workspace)
	elseif self.Options.type == "corner" then
		NewPart = Instance.new("CornerWedgePart", Services.Workspace)
	elseif self.Options.type == "cylinder" then
		NewPart = Instance.new("Part", Services.Workspace)
		NewPart.Shape = "Cylinder"
	elseif self.Options.type == "ball" then
		NewPart = Instance.new("Part", Services.Workspace)
		NewPart.Shape = "Ball"
	elseif self.Options.type == "seat" then
		NewPart = Instance.new("Seat", Services.Workspace)
	elseif self.Options.type == "vehicle seat" then
		NewPart = Instance.new("VehicleSeat", Services.Workspace)
	elseif self.Options.type == "spawn" then
		NewPart = Instance.new("SpawnLocation", Services.Workspace)
	end
	NewPart.Anchored = true

	-- Select the new part
	Selection:clear()
	Selection:add(NewPart)

	local HistoryRecord = {
		target = NewPart,
		apply = function(self)
			Selection:clear()
			if self.target then
				self.target.Parent = Services.Workspace
				Selection:add(self.target)
			end
		end,
		unapply = function(self)
			if self.target then
				self.target.Parent = nil
			end
		end,
	}
	History:add(HistoryRecord)

	-- Switch to the move tool and simulate clicking so
	-- that the user could easily position their new part
	equipTool(Tools.Move)
	Tools.Move.ManualTarget = NewPart
	NewPart.CFrame = CFrame.new(Mouse.Hit.p)
	Tools.Move.Listeners.Button1Down()
	Tools.Move.Listeners.Move()
end

Tools.NewPart.changeType = function(self, new_type)
	self.Options.type = new_type
	self.TypeDropdown:selectOption(new_type:upper())
	if self.TypeDropdown.open then
		self.TypeDropdown:toggle()
	end
end

Tools.NewPart.showGUI = function(self)
	-- Initialize the GUI if it's not ready yet
	if not self.GUI then
		local Container = Tool.Interfaces.BTNewPartToolGUI:Clone()
		Container.Parent = UI

		local TypeDropdown = createDropdown()
		self.TypeDropdown = TypeDropdown
		TypeDropdown.Frame.Parent = Container.TypeOption
		TypeDropdown.Frame.Position = UDim2.new(0, 70, 0, 0)
		TypeDropdown.Frame.Size = UDim2.new(0, 140, 0, 25)

		TypeDropdown:addOption("NORMAL").MouseButton1Up:connect(function()
			self:changeType("normal")
		end)
		TypeDropdown:addOption("TRUSS").MouseButton1Up:connect(function()
			self:changeType("truss")
		end)
		TypeDropdown:addOption("WEDGE").MouseButton1Up:connect(function()
			self:changeType("wedge")
		end)
		TypeDropdown:addOption("CORNER").MouseButton1Up:connect(function()
			self:changeType("corner")
		end)
		TypeDropdown:addOption("CYLINDER").MouseButton1Up:connect(function()
			self:changeType("cylinder")
		end)
		TypeDropdown:addOption("BALL").MouseButton1Up:connect(function()
			self:changeType("ball")
		end)
		TypeDropdown:addOption("SEAT").MouseButton1Up:connect(function()
			self:changeType("seat")
		end)
		TypeDropdown:addOption("VEHICLE SEAT").MouseButton1Up:connect(function()
			self:changeType("vehicle seat")
		end)
		TypeDropdown:addOption("SPAWN").MouseButton1Up:connect(function()
			self:changeType("spawn")
		end)

		self.GUI = Container
	end

	-- Reveal the GUI
	self.GUI.Visible = true
end

Tools.NewPart.hideGUI = function(self)
	-- Hide the GUI if it exists already
	if self.GUI then
		self.GUI.Visible = false
	end
end

Tools.NewPart.Loaded = true
