So I made a pet inventory system, and when the pet is shown on the frame, it is extremely small:
See that tiny speck of blue right there? that’s supposed to be a 2x2x2 sized pet.
My script:
local MainFrame = script.Parent
local ScrollingFrame = MainFrame:WaitForChild("ScrollingFrame")
local Info = MainFrame:WaitForChild("Info")
local EquipBTN = Info:WaitForChild("Equip")
local DisplayName = Info:WaitForChild("DisplayPetName")
local InfoViewport = Info:WaitForChild("ViewportFrame")
local temp = ScrollingFrame:WaitForChild("Template")
local RunService = game:GetService("RunService")
local selectedTemp
_G.CreateNewTemplate = function(petName)
local petModel = game.ReplicatedStorage.Pets:FindFirstChild(petName,true)
if petModel ~= nil then
local cloned = petModel:Clone()
cloned:SetPrimaryPartCFrame(CFrame.new(0,0,0))
local clonedTemp = temp:Clone()
clonedTemp.Parent = ScrollingFrame
clonedTemp.Visible = true
clonedTemp.Name = petName
local viewport = clonedTemp.ViewportFrame
petModel.Parent = viewport
local viewportCamera = Instance.new("Camera")
viewportCamera.Parent = viewport
local cf = cloned:GetPrimaryPartCFrame()
viewport.CurrentCamera = viewportCamera
viewportCamera.CFrame = CFrame.new(0,0,cloned.PrimaryPart.Size.Z*2)
RunService.RenderStepped:Connect(function()
cloned:SetPrimaryPartCFrame(cf * CFrame.Angles(0,math.rad(3),0))
end)
end
end
This is something I use for viewport frames. You may have to invert the “normal” variable.
“handle” is your pet’s hitbox.
if normal == "Front" then
normal = handle.CFrame.LookVector
elseif normal == "Back" then
normal = -handle.CFrame.LookVector
elseif normal == "Bottom" then
normal = -handle.CFrame.UpVector
elseif normal == "Top" then
normal = handle.CFrame.UpVector
elseif normal == "Right" then
normal = handle.CFrame.RightVector
elseif normal == "Left" then
normal = -handle.CFrame.RightVector
end
camera.CFrame = CFrame.new(handle.Position + normal * (-handle.Size.Magnitude/1.5), handle.Position)