function createItem(item)
local button = Instance.new('ImageButton')
button.AnchorPoint = Vector2.new(0.5, 0.5)
button.BackgroundTransparency = 1
button.Name = item.Name
button.Image = 'rbxassetid://295943248'
button.ScaleType = 'Slice'
button.SliceCenter = Rect.new(10, 10, 20, 20)
local viewport = Instance.new('ViewportFrame')
viewport.AnchorPoint = Vector2.new(0.5, 0.5)
viewport.Size = UDim2.new(0.8, 0, 0.8, 0)
viewport.Position = UDim2.new(0.5, 0, 0.5, 0)
viewport.BackgroundColor3 = Color3.new(1, 1, 1)
local camera = Instance.new('Camera')
viewport.CurrentCamera = camera
local clone = item:Clone()
clone.Parent = viewport
local cameraPosition = Vector3.new(3, 3, 3)
camera.CFrame = CFrame.new(cameraPosition, clone.PrimaryPart.Position)
local aspectRatio = Instance.new('UIAspectRatioConstraint')
aspectRatio.AspectType = 'ScaleWithParentSize'
camera.Parent = viewport
viewport.Parent = button
aspectRatio.Parent = button
button.Parent = buttons
end
The ViewPort is inside the grey box and the model has a bright green part so I should be able to see it. Any help?
It’s my first time using ViewportFrames, so if anyone has any good troubleshooting methods then please advise me