Trouble with scripting viewport [SOLVED]

What are you attempting to achieve?

I am attempting to make a view port display a pet model within a Billboard Gui through code.

What is the issue?

I am not getting any errors in the output and am unsure of what i am doing wrong. The model and camera are going into the view-port and the viewport.CurrentCamera is set to the correct camera.

What solutions have you tried so far?

I have tried Countless things. I have tried re positioning the camera, model, and rewriting the code. I have searched the devforum in an attempt to find similar issues and work off of that but have come to no success.


I will provide a screenshot and some code below:

local ModelItem = Database.PetModels:FindFirstChild(GetPets[n].Name):Clone()
			local ViewPortHolder = UIClone.ViewportFrame
			local ViewPort = UIClone.ViewportFrame
			local ViewPortCam ="Camera", workspace)
			local ViewPortCamPosition =, CoreModule.ViewPortZoomIncrement, CoreModule.ViewPortZoomIncrement)
			ModelItem.Parent = ViewPortHolder
			ModelItem.PrimaryPart.Position =,0,0)
			local ScriptClone = game.ReplicatedStorage.Scripts:FindFirstChild("ItemRotation"):Clone()
			ScriptClone.Parent = ModelItem
			ViewPortCam.Parent = ViewPort
			ViewPort.CurrentCamera = ViewPortCam
			ViewPortCam.CFrame =, ModelItem.Build.Body.Position)
			UIClone.ImageColor3 = CoreModule:GetRarityColor(Database.Pets:FindFirstChild(GetPets[n].Name).Rarity.Value)
			GetItems[i].MainBackground.PetFrame.CanvasSize =,0,0,GetItems[i].MainBackground.PetFrame.UIGridLayout.AbsoluteContentSize.Y)
			for i, v in pairs(ModelItem:GetDescendants()) do
				if v:IsA("Script") then
				elseif v:IsA("BasePart") then
					v.Anchored = true

Again i get no errors, and everything is in the correct place within the View Port Frame.

I am not sure if it is an issue with the CFrame, but i have tried multiple different things for that.

If you have any insights on what to do, or know where the problem is feel free to reply to the thread or DM me.

1 Like

Is your Billboard Gui a descendant of Player Gui?

1 Like

No, it is a descendant a part.

That’s why it’s not working.

Put it under Player Gui and set it’s Adornee to the part.

1 Like

Alright, so far that has fixed the main problem. Although why is only a single part of the model showing?


Im trying to get an outcome with the viewport showing the whole model.


This may help with what you are trying to do. Note it will create a viewport frame inside the parent-frame you want. In order for it to show above if you have your GUI ZIndexBehaviour set to Global, I would suggest adding a line where it creates the viewport frame, ZIndex = parentFrame.ZIndex + 1.

I used it for this:

If that face is a SurfaceGui, then you’re in trouble. SurfaceGuis can’t be displayed in ViewportFrames. You should replace that with a decal if that is the case.

1 Like

Ok, i will do that, but i still have the problem of only the main part displaying in the view port even though there are multiple parts within the model.

The ears might not be visible from that angle.

EDIT: Oh, and instead of

ModelItem.PrimaryPart.Position =,0,0)

Do this:

ModelItem:SetPrimaryPartCFrame(, 0, 0))

Otherwise the rest of the parts in your model won’t move.

They now appear in the view port, although the children of the model, except for the primary part are attached to the camera


What other parts are you including in the pet’s model? Remove them or create a model that only contains the pet.

These are all the parts that make up the pet
Inside the part above is the decal

1 Like

Mind removing ScriptClone for now and testing this again? It may be messing with your model.

That wasn’t the problem, i just found it. Also that script is deleted when the model is copied.
I added this:

ModelItem:SetPrimaryPartCFrame(, ModelItem.PrimaryPart.Position))

Thank you for all the help!