Viewport Camera won't update

  1. What do you want to achieve? Make the viewport camera show the players characters frontside. Front facing view of the player

  2. What is the issue? The CFrame won’t update/lock to the clone of the player. The camera is just way above the player and the camera is facing the characters backside

  3. What solutions have you tried so far? I’ve tried different CFrame values, tried adjusting the viewports size, and looked into the FOV but the camera just stays facing the backside of the character and above.

Is there anything I can do that I am missing? An obvious answer?

– Variables

local ViewportFrame = script.Parent
local Player = game.Players.LocalPlayer
local character = Player.Character
local Camera = Instance.new(“Camera”)

– The Camera

Camera.Parent = ViewportFrame
ViewportFrame.CurrentCamera = Camera
Camera.FieldOfView = 30 – this doesn’t really help cause the cframe is still not updated

– Function
wait(1)
function char()
ViewportFrame:ClearAllChildren()
character.Archivable = true
local CharsClone = character:Clone()
CharsClone.Parent = ViewportFrame
Camera.CFrame = CFrame.new(0,0,0) – this won’t put the cframe value no matter what I put there, so I just put the zeros for simplicity
Camera.CameraSubject = CharsClone
end

while true do
wait()
char()
end

If you’re working with camera’s and want control over the CFrame property try:
Camera.CameraType=Enum.CameraType.Scriptable

Some additional references for good context on camera behavior.

I’ve personally found this viewportframe tutorial really helpful in camera positioning: https://youtu.be/1q0-XAkXZpU
Also, there’s an open source inventory system that uses the player’s character in a viewport frame, I would also give that a shot. Open Source Advanced Inventory System

1 Like

Forgot to mention this in the og post my bad. I’ve also tried using Enum.CameraType.Scriptable, but it just offsets the camera to the right. Tried it with all CameraTypes and they just offset the camera one way or another.

I’ll check out the video and the inventory system. Thanks.

I checked out the Inventory system and it just uses the camera system by @boatbomber I used this before but I ran into a problem with it, which is why I don’t bother using it. As for the tutorial, I’ve made some changes but the CFrame just won’t update, regardless of position. Don’t know why.

I was able to duplicate something similar, but it’s nothing pretty or advance looking. x_x
cloneViewportFrameExample.rbxl (34.2 KB)
The code is located in StarterGui.

Thanks bro the code really helped out.

Edit: I found the problem and it’s a bug in my studio. I used your code and for some reason it worked then after clicking again, it went back to the same problem. Nevertheless, thank you, got some insight.

1 Like