I have the following script:
local S,E = pcall(function()
MainFrame.InformationFrame.CarModelText.Text = Car.Name
SelectedCar = {
Car = Car;
CarColor = nil;
PlateColor = nil;
}
local CarModel = game.ReplicatedStorage.Cars[Car.Name]
CarModel = CarModel:Clone()
CarModel.Parent = MainFrame.ImageFrame.ViewportFrame
for _,v in ipairs(MainFrame.ImageFrame.ViewportFrame:GetChildren()) do
if v:IsA("ModuleScript") then
CarModel = v
end
end
local viewportCamera = Instance.new("Camera")
MainFrame.ImageFrame.ViewportFrame.CurrentCamera = viewportCamera
viewportCamera.Parent = MainFrame.ImageFrame.ViewportFrame
viewportCamera.CameraType = Enum.CameraType.Orbital
viewportCamera.CameraSubject = require(CarModel).DriveSeat
end)
(Ignore the use of pcall, it is warranted just not shown here.)
By the time I create the Camera CarModel
is a module object, inside the module DriveSeat is a DriveSeat instance. All this works. How can I make the camera suit the DriveSeat so it shows it or orbits it, or something similar.