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

1 Like
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.

1 Like

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.

2 Likes

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

1 Like

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

--Fix?
AvCameraObj.CameraType = Enum.CameraType.Scriptable -- enable camera to be scripted

ViewportFrame.CurrentCamera = AvCameraObj -- set currentcamera
--


--Typpo error ig?
AvCameraObj.CFrame = AvCameraObj.CFrame -- ?????whats the purpose of setting the camera position to the current position itself which is (0,0,0)
--Should be this right?
AvCameraObj.CFrame = AvCameraPart.CFrame -- sounds more logical

--Btw what is this part
AvCameraPart.Transparency = 1 -- if you want this part to show then your setting it's transparency to 0 => not showing, invisible
--> Should be this right?
AvCameraPart.Transparency = 0 -- if you want it to show

correct me if Im wrong, and maybe I need more context so I can have a better understanding of what’s going on