Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
Viewport frames
A ViewportFrame uses a camera to render 3D objects into a 2D viewport. Ideal use cases include:
- A minimap of your game directly in the corner of a user's screen.
- 3D models of items in an inventory menu.
- Rotating objects that a character has equipped.
Viewport configurations
3D objects that users view through a ViewportFrame can either move with their camera, remain static, or rotate within the ViewportFrame. This object can also include a Sky child as a cubemap for reflections.
With Camera
If you want a 3D object to move with the camera:
Position your camera view within the game so that the object you want to see within the frame is visible.
Add a new
ViewportFrameto the screen and then make sure it's selected in the Explorer.In the Properties window, assign the
CurrentCameraproperty to the camera:- Select the
CurrentCameraproperty. Your cursor changes. - In the Explorer window, click on the top-level
Cameraobject.
- Select the
Parent the desired 3D object to the new
ViewportFrame. Note that if you still want to see the object within your game, you must duplicate it in theWorkspaceand then parent the duplicate object to theViewportFrame.
When you move your camera, the object will also move within the ViewportFrame.
Note
When you want to update the view of your ViewportFrame, be sure to update the camera, not the objects within the view.
Static
If you want the 3D object to remain static:
Position your camera view within the game so that the object you want to see is in the exact position you want to see it within the frame.
In the Explorer window, duplicate the top-level
Cameraobject, then rename it to an identifiable name likeViewportCam.Add a new
ViewportFrameto the screen and then make sure it's selected in the Explorer.In the Properties window, assign the frame's
CurrentCameraproperty to the duplicated camera:- Select the
CurrentCameraproperty. Your cursor changes. - In the Explorer window, click on the duplicated camera object.
- Select the
Parent the desired 3D object to the new
ViewportFrame. Note that if you still want to see the object within your game, you must duplicate it in theWorkspaceand then parent the duplicate object to theViewportFrame.
Rotation
If you want a 3D object such as a BasePart to rotate on its own within the frame:
Add a new
ViewportFrameto the screen.In the Explorer window, drag the desired
BasePartinto the newViewportFrame.Insert a new
LocalScriptinto theViewportFrameand paste in the following code.local RunService = game:GetService("RunService") local viewportFrame = script.Parent -- Parameters to experiment with local cameraDistance = 10 local cameraFieldOfView = 50 local objectPitchAngle = 40 local objectRotationSpeed = 50 -- Viewport camera initialization local viewportCamera = Instance.new("Camera") viewportCamera.FieldOfView = cameraFieldOfView viewportFrame.CurrentCamera = viewportCamera viewportCamera.Parent = viewportFrame -- Viewport object initialization local object = viewportFrame:FindFirstChildWhichIsA("BasePart") if object then object.CFrame = CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(objectPitchAngle), 0, 0) -- Update loop local t = 0 RunService.PostSimulation:Connect(function(delta) t += delta viewportCamera.CFrame = CFrame.Angles(0, math.rad(t * objectRotationSpeed), 0) * CFrame.new(0, 0, cameraDistance) end) else warn("3D object not found as child of viewport frame") end
Skybox Reflections
ViewportFrames can use a Sky child as a cubemap for reflections, in which case only the Sky object's six Skybox[…] properties are used. Assuming these properties are valid, lighting inside the ViewportFrame acts similarly to when Lighting.EnvironmentSpecularScale and Lighting.EnvironmentDiffuseScale are both set to 1.
To implement skybox cubemap reflections:
- Insert a
Skyobject as a direct child of theViewportFrame. - Set the
Skyobject's six texture properties (SkyboxBk,SkyboxDn,SkyboxFt,SkyboxLf,SkyboxRt,SkyboxUp). - For
Partsthat should appear within the frame, set theirReflectanceproperty greater than 0, or use a reflectant material likeGlassorFoil. ForMeshPartsthat should appear within the frame, apply aSurfaceAppearancewith a properly-configuredMetalnessMap.
Lighting and appearance
Lighting within a ViewportFrame is controlled through three properties:
| Property | Description |
|---|---|
| [`Ambient`](/docs/viewportframe#viewportframe-ambient) | Determines the overall lighting hue applied to the area within the viewport frame. Defaults to [`Color3.fromRGB(200, 200, 200)`](/docs/color3#color3-fromrgb) (ghost grey). |
| [`LightDirection`](/docs/viewportframe#viewportframe-lightdirection) | A [`Vector3`](/docs/vector3) representing the direction of the light source from position `(0, 0, 0)` . Defaults to `(-1, -1, -1)` . |
| [`LightColor`](/docs/viewportframe#viewportframe-lightcolor) | Color of the directional light. Defaults to [`Color3.fromRGB(140, 140, 140)`](/docs/color3#color3-fromrgb) (silver). |
Additionally, you can adjust the overall rendered appearance of the viewport throuugh the following properties:
| Property | Description |
|---|---|
| [`ImageColor3`](/docs/viewportframe#viewportframe-imagecolor3) | Changes the image color/tint without modification of the rendered object. The default colorization value is [`Color3.new(1, 1, 1)`](/docs/color3#color3-new) (white) at which no color modification occurs. |
| [`ImageTransparency`](/docs/viewportframe#viewportframe-imagetransparency) | Changes the image transparency without modification of the rendered object. A value of `0` (default) is completely opaque and a value of `1` is completely transparent (invisible). |