---------------
--// Functions
---------------

local function toggleBuild()
	if sellMode then
		button.BackgroundColor3 = Color3.new(0.658824, 0.368627, 0.345098)
	else
		button.BackgroundColor3 = Color3.new(0.658824, 0.658824, 0.658824)
	end
end

local function pickupModeVisuals()
	while sellMode do
		task.wait(.01)
		pcall(function()
			local object = Mouse.Target
			local selected = nil


			local P = object.Parent
			local PP = object.Parent.Parent
			local PPP = object.Parent.Parent.Parent
			local TANG = nil

			if P.Name == "Builds" then
				TANG = object
			elseif PP.Name == "Builds" then
				TANG = P
			elseif PPP.Name == "Builds" then
				TANG = PP
			end

			if (object) and (TANG) then
				if TANG ~= selected then
					selected = TANG
					-- Not undo everything if already done
					-- Replace existing

					pcall(function()
						Part:Destroy()
					end)

					Part = Instance.new("Part")
					Part.Size = Vector3.new(5,5,5)
					Part.Color = Color3.new(1,0,0)
					Part.Parent = workspace
					Part.Transparency = 0.8
					Part.Anchored = true
					Part.CanCollide = false
					Part.CanQuery = false
					Part.CanTouch = false

					local SelectionBox = Instance.new("SelectionBox")
					SelectionBox.Color3 = Color3.new(1,0,0)
					SelectionBox.Adornee = Part
					SelectionBox.Parent = Part
					SelectionBox.LineThickness = 0.025
					
					local X,Y,Z
					
					if TANG:IsA("Model") then
						
						X,Y,Z = TANG:GetBoundingBox().X, TANG:GetBoundingBox().Y, TANG:GetBoundingBox().Z

					else
						X,Y,Z = TANG.Position.X, TANG.Position.Z, TANG.Position.Z

					end
					
					Part.Position = Vector3.new(X,2.6,Z)

				end
			else
				pcall(function()
					Part:Destroy()
				end)
			end	
		end)
	end
end
