Pet Model not showing up in Viewport

I’ve tried everything, my problem is when I walk up to the egg and the billboard gui shows, the pet model isnt showing up in my template. The weird thing is when I turn the viewport background transparency to 0 and put it inside a screengui, the viewport is white, showing like it should but when the transparency is still on 0 and inside my billboard gui , it doesnt show up at all. I don’t know if this is a code problem but yeah here is my script.

local player = game.Players.LocalPlayer
local eggFolder = workspace.EggFolder
local character = player.Character or player.CharacterAdded:Wait()

local hrp = character:WaitForChild("HumanoidRootPart")
local runService = game:GetService("RunService")

runService.Heartbeat:Connect(function(dt)
	for _,v in eggFolder:GetChildren() do
		if v:IsA("Model") then
			local hitbox = v:FindFirstChild("Proximity")
			if hitbox then
				local distance = (hitbox.Position - hrp.Position).Magnitude
				if distance <= 8 then
					if not hitbox:FindFirstChildWhichIsA("BillboardGui") then
						local egg = v.Name
						local eggUI = game.ReplicatedStorage.EggGui.EggUI:Clone()
						eggUI.Parent = hitbox
						local wins = v:GetAttribute("Wins")
						eggUI.Frame.Cost.AmountText.Text = "🏆"..wins
						local holder = eggUI.Frame.PetHolderLabel
						local eggData = game.ReplicatedStorage.Events.GetEggInfo:InvokeServer(v.Name)

						for _, pet in eggData do
							local template = eggUI.Frame.PetGuiTemplate:Clone()
							template.Parent = eggUI.Frame.PetHolderLabel
							template.Visible = true

							local viewPortFrame = template.Frame.ViewportFrame
							if viewPortFrame then
								local petModel = game.ReplicatedStorage.PetPack:FindFirstChild(pet.Name):Clone()
								petModel.Parent = viewPortFrame

								local camera = Instance.new("Camera")
								camera.CFrame = CFrame.new(petModel.PrimaryPart.Position + (petModel.PrimaryPart.CFrame.lookVector * 1.75), petModel.PrimaryPart.Position)
								camera.Parent = viewPortFrame
								viewPortFrame.CurrentCamera = camera
							end
						end
					end
				else
					if hitbox:FindFirstChildWhichIsA("BillboardGui") then
						hitbox:FindFirstChildWhichIsA("BillboardGui"):Destroy()
					end
				end
			end
		end
	end
end)
1 Like

I heard viewports only show up in billboard guis when the billboard gui is inside playergui. If anyone can confirm that that’d be amazing.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.