Hello I am trying to do a viewport frame script. The problem is when i'm using a CFrame for a camera for the viewport frame this happens
14:28:09.213 - game.Workspace.Viewportcam.CFrame = game.Workspace.Cam.CFrame.LookVector:1: invalid argument #3 (CFrame expected, got Vector3) 14:28:09.215 - Stack Begin 14:28:09.225 - Script 'game.Workspace.Viewportcam.CFrame = game.Workspace.Cam.CFrame.LookVector', Line 1 14:28:09.227 - Stack End
What I want to achieve is there is a part above the viewport frame that the camera will face In front of. Now I actually do know that look vector is meant for vector3 but is there a way to use it in a CFrame? Here is the code
game.Workspace.Viewportcam.CFrame = game.Workspace.Cam.CFrame.LookVector * 5
game.StarterGui.SurfaceGui.ViewportFrame.CurrentCamera = game.Workspace.Viewportcam
game.Workspace.Viewportcam.CameraType = Enum.CameraType.Scriptable
game.Workspace.Viewportcam.CameraSubject = game.Workspace.Cam
for i,v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("BasePart") then
local vclone = v:Clone()
vclone.Parent = game.StarterGui.SurfaceGui.ViewportFrame
game["Run Service"].RenderStepped:Connect(function()
vclone.CFrame = v.CFrame
end)
end
end
For some more info
The local script is in replicated first
Camera is in workspace
Gui is a SurfaceGui (I could use billboard but I want to use surfacegui for this case.)
But in advance thanks!

3 comments
You are using the CFrame incorrectly check out the CFrame Developer article on it https://developer.roblox.com/en-us/api-reference/datatype/CFrame
Wait i think i realized do i have to add the look vector to the cframe?
"game.Workspace.Cam.CFrame.LookVector * 5" What were you trying to do