Moving the camera in a ViewPortFrame does nothing

i have code:

local model = script.Parent:FindFirstChildWhichIsA("Model")
local PrimaryPart = model.PrimaryPart

local tau = 2*math.pi
local t = 0
local cam = script.Parent.CurrentCamera
local radius = 5

local p = Instance.new("Part", workspace)
p.Anchored = true
p.Position = model.PrimaryPart.Position

while true do
	t += tau / 100
	cam.Position = CFrame.new(Vector3.new(math.sin(t)*radius, 0, math.cos(t)*radius), Vector3.new())
	wait()
end

This code works, outside of the ViewPort but inside, it doesn’t do anything.

You need to set the ViewportFrame.CurrentCamera to the camera you are using to render the object

1 Like

i have done that. It would have errored out if I did not.

I noticed another thing. Cam doesn’t have position property, it should be CFrame

Players.sfdstudios.PlayerGui.SpareGUI.ViewportFrame.ViewPort:15: attempt to index nil with 'CFrame'

I can’t tell if something with the math is wrong so if that’s the case then that would be helpful to know.