ViewportFrames not showing

I have this crate opening gui with in every slot a viewportframe, you can see the background of the viewportFrame, but when you play the game they are invisible. I don’t change anything about the frame, only that they are cloned when a frame is opend. There’s nothing wrong with the script nor the startergui

Are you sure there is nothing wrong with the script?

Please post your client / serversided scripts

local function viewportTower(tower, viewportFrame)
	local towerClone = towerFolder[tower]:Clone()
	towerClone.Parent = viewportFrame

	local camera = Instance.new("Camera")
	camera.Parent = viewportFrame
	viewportFrame.CurrentCamera = camera
	
	local npcPrimaryPart = towerClone.PrimaryPart or towerClone:FindFirstChildWhichIsA("BasePart")

	if npcPrimaryPart then
		local modelSize = towerClone:GetExtentsSize()
		local center = towerClone:GetBoundingBox().Position

		camera.CFrame = CFrame.lookAt(center + Vector3.new(0, modelSize.Y, modelSize.Magnitude), center)
	end
end

is the viewportFrame argument that is passed a descendant of a screengui in the playergui? (Not startergui!)

no i loop thorugh a bunch of them