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.
Info
I will provide a screenshot and some code below:
Code
local ModelItem = Database.PetModels:FindFirstChild(GetPets[n].Name):Clone()
local ViewPortHolder = UIClone.ViewportFrame
local ViewPort = UIClone.ViewportFrame
local ViewPortCam = Instance.new("Camera", workspace)
local ViewPortCamPosition = Vector3.new(CoreModule.ViewPortZoomIncrement, CoreModule.ViewPortZoomIncrement, CoreModule.ViewPortZoomIncrement)
ModelItem.Parent = ViewPortHolder
ModelItem.PrimaryPart.Position = Vector3.new(0,0,0)
local ScriptClone = game.ReplicatedStorage.Scripts:FindFirstChild("ItemRotation"):Clone()
ScriptClone.Parent = ModelItem
ViewPortCam.Parent = ViewPort
ViewPort.CurrentCamera = ViewPortCam
ViewPortCam.CFrame = CFrame.new(ViewPortCamPosition, ModelItem.Build.Body.Position)
UIClone.ImageColor3 = CoreModule:GetRarityColor(Database.Pets:FindFirstChild(GetPets[n].Name).Rarity.Value)
GetItems[i].MainBackground.PetFrame.CanvasSize = UDim2.new(0,0,0,GetItems[i].MainBackground.PetFrame.UIGridLayout.AbsoluteContentSize.Y)
for i, v in pairs(ModelItem:GetDescendants()) do
if v:IsA("Script") then
v:Destroy()
elseif v:IsA("BasePart") then
v.Anchored = true
end
end
Again i get no errors, and everything is in the correct place within the View Port Frame.
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.
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.
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.