Render a camera view in a viewport frame

Since I am pretty bad with viewort frame, I decided to open this topic.
So i’m trying to render a camera view in a viewport frame (something like in the image below)

But from what I’ve seen so far, only the player character or a part is rendered. I know that it has a “CurrentCamera” property but I don’t really know how to use it. Any idea?


What is the issue? Are you trying to mimic/construct this picture? It would be best if you show your code and picture of your result

The result is a blank white square, I am here to see if you have some idea of what can I use to achieve the result of this photo montage

Did you put a WorldModel inside of the viewport frame?

After a little bit of playing around I’ve managed to get this working. I’d like to give thanks to @XAXA for their SkyBox model (which can be used to emulate skyboxes in WorldModels).

Here’s the script I wrote.

local run = game:GetService("RunService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local clientCamera = workspace.CurrentCamera
local gui = script.Parent
local viewportFrame = gui:WaitForChild("ViewportFrame")
local worldModel = viewportFrame:WaitForChild("WorldModel")
local viewportCamera ="Camera")
viewportFrame.CurrentCamera = viewportCamera
viewportCamera.Parent = viewportFrame


character.Archivable = true
local characterClone = character:Clone()
characterClone.Parent = worldModel
characterClone.Humanoid.NameDisplayDistance = 0
characterClone.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Subject

	viewportCamera.CFrame = clientCamera.CFrame

Here’s the model file if you’d like to see how everything is organised:
model.rbxm (8.2 KB)


Okay, so I know this is a somewhat old post, but I was wondering, after a while the model stops working… Any reason why? I am a beginner scripter/GUI designer and would really appreciate the reply!


have you found it out? i still have the problem