How to use viewportframe

I’m not sure what the problem may be, I’ll check my computer ASAP

local clone = data.Template:Clone()
clone.Parent = data

local object = game.ReplicatedStorage.Info[v.Name][A.Name].Lv1:Clone()
object.Parent = clone.ViewportFrame
					
local camera = Instance.new("Camera")
camera.Parent = clone
					
clone.ViewportFrame.CurrentCamera = camera
camera.Focus.Position = object:GetPivot().Position + Vector3.new(object:GetPivot().Position * 2, 0, 0)
1 Like

Just tested with Studio’s camera, you apparently need soemthgin called CoordinateFrame, not a Vector3

you mean CFrame? wwwwwwwwwwwwwwwwwwwww

If its CFrame I do

camera.Focus = CFrame.new(object:GetPivot().Position + Vector3.new(object:GetPivot().Position * 2, 0, 0))

I am pretty sure
image
however nothing pops up
image
image

It’s growing an error:
invalid argument, CFrame expected, got Vector3

IDK how to solve this, sorry

Found something that could be useful:

yes I know. I know what a CFrame is.

camera.Focus = CFrame.new(object:GetPivot().Position + Vector3.new(object:GetPivot().Position * 2, 0, 0))

image

is a CFrame or coordinateFrame

What, the Camwra is under the Frame? If I’m not wrong taht doesn’t work, could be me tho

Okay, then I think you need to get the primary parts position, like:

camera.Position = model.PrimaryPart.Position + CFrame.new(model:GetPivot.Position * 2, 0, 0)

You cannot add a vector3 to a CFrame. You also cannot set the position to a CFrame.

to set an objects CFrame you do

object.CFrame = (cframe)

in the case, you are only able to set the cameras focus to a CFrame and not vector3. A CFrame is the combination of both a vector3 position and a orientation into one thing.

to manage a CFrame you can do

CFrame = CFrame.New(Vector3.new(pos,pos,pos)) * CFrame.Angles(Vector3.new(orientation,orientation,orientation))

Forgot that the pivot used Vector3, simply use the PrimaryParts size, taht might work

pivot gives you a CFrame. CFrame.Position gives you a vector3. You may need to read up on how to code for roblox.

for beginners like you!

1 Like

This module seems to do what you’re asking for, with an explanation here

I don’t use modules, sorry. I don’t think what I’m doing requires more than 10 lines of code and I want to just code it instead of over complicating things with unnecescary scripts and potential backdoors. I also looked at the preview and its spinning the objects in the viewportframe while also have some complex
“scale” option. I don’t need extra code I just want to make the object go in my viewportframe. I don’t need any auto adjusting, rotating objects.

You’re supposed to put a World Model into the Viewport Frame and put your parts in there. Or maybe the camera’s CFrame is wrong (That’s what I’m seeing, but I think it’s the World Model).

Can you show me the children of the Viewport Frame?

please look at my previous replies which I supplied images which show information pertaining to how I have things sset up

1 Like

image
I tried and it still doesnt work
image

local clone = data.Template:Clone()
clone.Parent = data

local object = game.ReplicatedStorage.Info[v.Name][A.Name].Lv1:Clone()
object.Parent = clone.ViewportFrame
					
local camera = Instance.new("Camera")
camera.Parent = clone
					
clone.ViewportFrame.CurrentCamera = camera
camera.Focus.Position = object:GetPivot().Position + Vector3.new(object:GetPivot().Position * 2, 0, 0)

You gotta put your model in the World Model. Everything you see in the viewport goes in the World Model. + I would put the camera inside the Viewport Frame just in case.

image

image

Is the Viewport Frame big enough?