Viewportframe Camera zoomed out

Hello there,
I’m currently trying to display a Character in workspace in a Viewport Frame.
Though, the Camera is zoomed out a lot and so the Character is very tiny.
I’m struggling to find out what I did wrong.

Summary

Unbenannt

The Code:

local Character = game.Workspace.Dummy

    local ViewportFrame = script.Parent.ViewportFrame

    Character:Clone()

    Character.Parent = ViewportFrame

    local viewportCamera = Instance.new("Camera")

    ViewportFrame.CurrentCamera = viewportCamera

    viewportCamera.Parent = ViewportFrame

    viewportCamera.CFrame = CFrame.new(Vector3.new(0, 0, 0), Character.HumanoidRootPart.Position)

I’ve tried changing the Vector Numbers but that results in it zooming out even further
PS: I’m quite new to scripting
Anyone able to help me? Thanks!

1 Like

You’re setting it to 0,0,0 which is probably nowhere near, I’d base it’s position of where the Character’s Head is.
Usually, I do this:

viewportCamera.CFrame = Character.Head.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0, math.rad(180), 0)

Decrease the -3 to -4 etc to make it zoom out, increase the -3 to -2 etc to zoom in.

3 Likes

Thank you a lot! Worked perfectly!

1 Like