So I have a new camera being made for use with a viewportframe, the camera’s position is made to be set to the position of another object, which I use as the reference point of where the camera should go using
itemPreviewCamera.CFrame = CFrame.lookAt(itemPositionReference.CFrame.Position, modelPreview.PrimaryPart.CFrame.Position)
If I understand correctly this should position the camera to the itemPositionReference (the part I am using as a reference of position) and point it torwards modelPreview (the item displayed within the viewportframe)
However, after a bit of (albeit not entirely accurate) fiddling (as studio for some reason doesn’t visually display where cameras are) I managed to determine that the camera is just sitting in the sky around the middle of the workspace, not facing the target, which means neither part of the lookAt worked.
The full code if needed for some reason
player = game:GetService(“Players”).LocalPlayer
itemPreviewCamera = Instance.new(“Camera”)
itemPreviewCamera.Name = “Item Preview Camera”
itemPreviewCamera.Parent = script.Parent
script.Parent.CurrentCamera = itemPreviewCamera`
modelPreview = nil`
player.Backpack.ChildAdded:Connect(function()
–print(“test”)
local model = player.Backpack:FindFirstChildWhichIsA(“Model”)
modelPreview = model:Clone()
modelPreview.Parent = script.Parent
local itemPositionReference = workspace[“Item Reference”][“Position Reference”]
modelPreview.PrimaryPart:PivotTo(itemPositionReference:GetPivot())
print(modelPreview)
modelPreview.PrimaryPart.CFrame.Position)
itemPreviewCamera.CFrame = CFrame.lookAt(itemPositionReference.CFrame.Position, modelPreview.PrimaryPart.CFrame.Position)
end)
player.Backpack.ChildRemoved:Connect(function()
modelPreview = nil
end)```
I’m not too experienced with viewportframes or cameras, and am I bit low knowledged on CFrames, so apologies.