Viewport Frame not showing anything

Hello guys!

Recently I have been working on a loading screen + main menu system. I wrote a local script for the loading part, and I made character preview using viewport frame. When everything is loaded, the script clones the player’s character and removes scripts, hats/accessories from it, it’s working perfectly.
But the viewport frame doesn’t show anything, I even used the template from the developer site.

It looks exactly like this:

local AvCameraPart = Instance.new("Part")
AvCameraPart.Name = "AvPart"
AvCameraPart.Position = Vector3.new(0, 46.5, -230)
AvCameraPart.Rotation = Vector3.new(0, 180, 0)
AvCameraPart.Transparency = 1
AvCameraPart.Parent = game.Players.LocalPlayer.PlayerGui.game.Menu.Teams.Preview
local AvCameraObj = Instance.new("Camera")

AvCameraObj.Name = "AvCamera"
game.Players.LocalPlayer.PlayerGui.game.Menu.Teams.Preview.CurrentCamera = AvCameraObj
AvCameraObj.Parent = game.Players.LocalPlayer.PlayerGui.game.Menu.Teams.Preview

AvCameraObj.CFrame = AvCameraObj.CFrame

Any ideas to make it work? I would appreciate it a lot!
Thanks

local AvCameraPart = Instance.new("Part")
AvCameraPart.Name = "AvPart"
AvCameraPart.Position = Vector3.new(0, 46.5, -230)
AvCameraPart.Rotation = Vector3.new(0, 180, 0)
AvCameraPart.Transparency = 1 -- Parts with transparency set to 1 are invisible
AvCameraPart.Parent = game.Players.LocalPlayer.PlayerGui.game.Menu.Teams.Preview
local AvCameraObj = Instance.new("Camera")

AvCameraObj.Name = "AvCamera"
game.Players.LocalPlayer.PlayerGui.game.Menu.Teams.Preview.CurrentCamera = AvCameraObj
AvCameraObj.Parent = game.Players.LocalPlayer.PlayerGui.game.Menu.Teams.Preview
AvCameraObj.CFrame = AvCameraObj.CFrame -- These CFrames are identical

EDIT: I realized for what you could use AvCameraPart. I think that the last line of code is the issue.

The viewport Frame have their own coordinate system.

If you say the part is at 0, 46.5, -230. You are placing it somewhere that is away from the viewportFrame line of sight. Use 0, 0, 0 to start and move it as you need to.

1 Like

I’m sorry, have no idea how I missed that, but it’s still not working. I was also trying with

AvCameraObj.CFrame = CFrame.new(Vector3.new(0, 2, 12), AvCameraPart.Position)

in the first place from the template I mentioned with the same result. @Spiderr12PL

I moved it to the origin point (0,0,0) but the viewport frame was still black/emtpy, I mean it basicly has a dark fram behind it. @cowwy_yt

u need to Change the Camera Type to Scriptable

Repeat
wait()
Workspace.CurrentCamera.CameraType = Enum.CameraType .Scriptable
Until Workspace.CurrentCamera.CameraType == Enum.CameraType .Scriptable
– Code