I’m having trouble setting a pet on a Viewport. I tried many CFrame angles with 5 studs but none showed the pet on the Viewport.
for _, capsule in ipairs(game.Workspace.PetShop:GetChildren()) do
local Template = capsule.UI.CoinEgg.Chances.Inner.Table.ContainerScroll.Template
for _, pet in ipairs(capsule.PossiblePets:GetChildren()) do
local NewTemplate = Template:Clone()
local VPcamera: Camera = Instance.new('Camera')
local Viewport: ViewportFrame = NewTemplate.Inner.Pet
local Item = game.ReplicatedStorage.Animals[pet.Name]:Clone()
Viewport.CurrentCamera = VPcamera
Item.HumanoidRootPart.Anchored = true
Item.Parent = Viewport
VPcamera.Parent = Viewport
VPcamera.CFrame = Item.HumanoidRootPart.CFrame * CFrame.new(0, 0, 5)
NewTemplate.Parent = capsule.UI.CoinEgg.Chances.Inner.Table.ContainerScroll
end
Template:Destroy()
end
When I tried to set a basic part to the Viewport, it just worked. Then tried a model with a part inside and worked again. But is not working with the pet.
I have tried all of these
local root: BasePart = Item.HumanoidRootPart
VPcamera.CFrame = Item.HumanoidRootPart.CFrame * CFrame.new(0, 5, 0)
VPcamera.CFrame = CFrame.new(root.Position + root.CFrame.LookVector * 5, root.Position)
VPcamera.CFrame = root.CFrame:ToObjectSpace(CFrame.new(0, 0, 5))
Item.HumanoidRootPart.CFrame = (VPcamera.CFrame * CFrame.new(0, 0, -5))
All pets are rigged
Any help or adjustments are welcome.