--	if game.ReplicatedStorage.Tools:FindFirstChild(Object.Name) then

	if Object:FindFirstChild("Handle") and not Rotation then -- Soybeen added 7/29/2020
		Rotation = Vector3.new(0,90,0)
	end
	
	
	local Cam = Instance.new("Camera",Viewport)
	
	Cam.FieldOfView = 50
	
	Object = Object:Clone()
	
	Object.Parent = Viewport
	
	Cam.CameraType = Enum.CameraType.Scriptable
	
	Cam.CameraSubject = Object
	
	Viewport.CurrentCamera = Cam
	
	-- Size viewport and adjust properties.
	Viewport.Size = UDim2.new(1,0,1,0)
	
	Viewport.Position = UDim2.new(0.5,0,0.5,0)
	
	Viewport.AnchorPoint = Vector2.new(0.5,0.5)
	
	Viewport.BackgroundTransparency = 1 
	
	Viewport.BackgroundColor3 = Color3.fromRGB(0,0,0)
	
	local function GetLongestSide(VectorThree)
		local LongestSide = VectorThree.X
		
		if VectorThree.Y > LongestSide then
			LongestSide = VectorThree.Y
		end
		
		if VectorThree.Z > LongestSide then
			LongestSide = VectorThree.Z
		end
		
		return LongestSide
	end
	
	-- Position camera relative to object size average.
	if Object:IsA("BasePart") then
		local Offset = distanceOverride or GetLongestSide(Object.Size)
		
		--local avgsize = (Object.Size.X + Object.Size.Y + Object.Size.Z) / 3
		
		Object.CFrame = CFrame.new(0,0,0) * CFrame.Angles(math.rad(Rotation.X),math.rad(Rotation.Y),math.rad(Rotation.Z)) 
		
		Cam.CFrame =  CFrame.new(0,0,Offset + (1.5 * (Offset/4)))
		
		Cam.CFrame = CFrame.new(Cam.CFrame.p,Object.Position)
				
		
	elseif Object:IsA("Model") and Object.PrimaryPart then
		local Extents = Object:GetExtentsSize()
		
		local Offset = distanceOverride or GetLongestSide(Extents) --(Extents.X + Extents.Y + Extents.Z) / 3
		
		local ModelMiddlePos = Vector3.new(Extents.X/2,Extents.Y/2,Extents.Z/2)
		
		Object:SetPrimaryPartCFrame(CFrame.new(0,0,0) * CFrame.Angles(math.rad(Rotation.X),math.rad(Rotation.Y),math.rad(Rotation.Z)))
		
		if Offset/4 >= 1 then
			Cam.CFrame = CFrame.new(Object:GetModelCFrame().p) * CFrame.new(0,0,Offset + (1.5 * (Offset/4)))
		else
			Cam.CFrame = CFrame.new(Object:GetModelCFrame().p) * CFrame.new(0,0,Offset + 1.5)
		end
		
		Cam.CFrame = CFrame.new(Cam.CFrame.p,Object:GetModelCFrame().p)
	else
		Object:Destroy()
		Viewport:Destroy()
		return
	end
	
	if Viewport.Parent ~= parent then
		Viewport.Parent = parent
	end
	
	Viewport.ZIndex = parent.ZIndex
	
	if parent:IsA("ImageLabel") then
		parent.Image = ""
	end
	
	return Viewport
end


return VC
