My viewport frame don't work

Hello!

I tried to make a viewport frame on a surface gui on a part. On the explorer, It look like this:
image
I also made a regular script to create the camera and position it (The script called “Camera” in the explorer)

In this script, I put this code:

local viewportFrame = script.Parent.ViewportFrame
local viewportCamera = Instance.new("Camera")
viewportFrame.CurrentCamera = viewportCamera
viewportCamera.Parent = viewportFrame
viewportCamera.CFrame = CFrame.new(viewportFrame["12StudJump"].CameraZone.Position, viewportFrame["12StudJump"].CameraTarget.Position)

I need help because the script don’t work:

The transparency of the part “cameraTarget” is 0 and “cameraTarget” must be visible on the viewport frame but the viewport frame stay empry when I launch the game.

Could you help me please?

Parenting and set the CFrame of the camera first, and then set the currentcamera

I tried to do this but it don’t work.

Is there any errors in the output?

No, there aren’t errors in the output.

Are you sure the parts camerazone and cameratarget is correctly positioned or not switched by accident?

Yes, I am sure of that. They’re correctly positioned.

It must be done in a localscript as cameras aren’t replicated.

What thing must I create with the local script? The camera? The parts who must be displayed? The ViewportFrame?

The camera must be created on the client.

Like this?

local viewportFrame = script.Value.Value --This is the ViewportFrame
local viewportCamera = Instance.new("Camera")
viewportCamera.CFrame = CFrame.new(viewportFrame["12StudJump"].CameraZone.Position, viewportFrame["12StudJump"].CameraTarget.Position)
viewportCamera.Parent = viewportFrame
viewportFrame.CurrentCamera = viewportCamera

This script don’t work.

You can keep this line in the localscript.