- I want to create a viewport camera that consistently updates It’s CFrame by copying the CurrentCamera’s CFrame, but not directly using the Workspace.CurrentCamera as the ViewportFrames CurrentCamera property.
[LocalScript] Located in StarterGui.SurfaceGui.ViewportFrame
local Workspace = game:GetService("Workspace")
local function updateCamera()
local currentCamera = Workspace.CurrentCamera
local viewCamera = script.Parent.Camera
if viewCamera then
viewCamera.CFrame = currentCamera.CFrame
end
end
-- Initial update
updateCamera()
-- Connect the update function to the CurrentCamera property change signal
Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(updateCamera)
-- Continuously update the ViewCamera's CFrame
while true do
updateCamera()
task.wait(0.1) -- Adjust the wait time as needed
end