Viewport frames not working

Hello. I am making a simulator an my viewport frames inside of my inventory is not working. This is the code that creates it:

function view:InventoryViewPoint(params)
	local petModel = game.ReplicatedStorage.__Inventory.Pets:FindFirstChild(params.Name);
	local clone = petModel:Clone();
	local viewPort1 = script.petTemplate:Clone()
	viewPort1.Name = params.Name;
	local viewPort = Instance.new("ViewportFrame", viewPort1.Main.Top)
	viewPort1.Parent = params.Parent;
	viewPort.Size = UDim2.new(1,0,1,0)
	viewPort.Position = UDim2.new(0,0,0,0)
	viewPort.BackgroundTransparency = 1
	local camera = Instance.new("Camera")
	viewPort.Name = params.Name;
	camera.Parent = viewPort;
	viewPort.ClipsDescendants = true
	viewPort.CurrentCamera = camera;

	return params.Parent;
end

This code uses it:

local temp = require(script.Viewport):InventoryViewPoint({
				Name = value.Name;
				Parent = f;
			})

However, the image on the viewport isn’t displaying.
First time using viewports by the way.

You have to set the Camera’s CFrame so you can actually see the object inside the ViewportFrame.

I’ve tried to with:

local primaryPart = clone.PrimaryPart
local pos = primaryPart.Position
camera.CFrame = CFrame.new(pos + primaryPart.CFrame.LookVector * 5, pos)

Which gave the same result. :sad:

Are you remembering to set the object’s Parent to the ViewportFrame?

That just fixed all of my problems… Can’t believe I let that slip through ahahah! Thank you so much. Just saved me a few hours :smile: