I am trying to script an inventory system for my game and when I try to use viewports to show the tool, they don’t show up. I am using the module ViewportFitter. Here is my code:
for name, data in Data do
local Slot = InventoryUI.Templates.ItemSlot:Clone()
Slot.Visible = true
local Tool = RP["New Models"][name]:Clone()
Tool.Parent = Slot.ModelViewport
local Camera = Instance.new("Camera")
Camera.Parent = Slot.ModelViewport
Slot.ModelViewport.CurrentCamera = Camera
local Rotator = VPFitter.new(Slot.ModelViewport, Camera)
Rotator:SetModel(Tool)
Rotator:Calibrate()
local ItemConfig = require(Tool.Configuration)
local ItemModelCFrame = ItemConfig.ViewportAngle
local ItemRarity = ItemRarities:GetItemRarity(Tool.Name)
local ItemColor = ItemRarities:GetItemColor(ItemRarity)
Slot.ModelViewport.CurrentCamera.CFrame = Rotator:GetMinimumFitCFrame(ItemModelCFrame.Rotation)
Slot.ItemTitle.Text = name
Slot.RarityGlow.ImageColor3 = ItemColor.Glow
Slot.Rarity.Text = ItemColor.TXT
Slot.Rarity.TextColor3 = ItemColor.Glow
Slot.Parent = ItemList.ScrollingFrame
end
Seems like the tool is not positioned correctly and here is the outcome: