I have created a ViewportFrame designed to hold a Part. This Part is cloned into the ViewportFrame from the workspace. Once the Part is in the ViewportFrame, the camera for the ViewportFrame is programmed to be offset by 7 studs in the Z-axis and angled at 2.5 radians on the Y-axis relative to the Part. However, it all works perfectly fine in studio but not in game. When in game, the viewport just appears blank. Additionally, no errors appear on the Developer Console.
Below is the code for manipulating the camera in the ViewportFrame:
local position = Part.CFrame *CFrame.Angles(0, 2.5, 0) *CFrame.new(0,0,7)
position = position.p + Part.Position
viewportCamera.CFrame = CFrame.new(position,Part.Position)
I have been struggling to find the cause of the issue for many hours. Any help will be greatly appreciated.
When there is no error printed on the dev console, try the print debug. add a print line between every line since your code got only 3 lines. (this is my only idea sorry)
I have done this, but I then decided to print ‘ViewportCamera.CFrame’ at the end of the code. In studio the printed ‘ViewportCamera.CFrame’ was different to the one printed in game.
I have put all numbers to 2 decimal places just to make it easier to read. As you can see, they both print something different even though it is the same code.