I’m trying to create an overhead camera, but it just spazzes out for seemingly no reason? I’m not switching between 2 CFrames, which is what it looks like here. This is the only chunk of code affecting the camera CFrame

self.Trove = Trove.new()
self.Trove:Connect(RunService.RenderStepped, function()
local MouseLocation = UserInputService:GetMouseLocation()
if UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then
if self.LastMouseLocation then
-- local Delta = self.LastMouseLocation - MouseLocation
-- Camera.CFrame += Camera.CFrame.RightVector * (Delta.X / 2)
-- Camera.CFrame += Camera.CFrame.UpVector * (-Delta.Y / 2)
end
end
self.LastMouseLocation = MouseLocation
local MinCorner = self.MinPoint
local MaxCorner = self.MaxPoint
local CameraPosition = Camera.CFrame.Position
Camera.CFrame = CFrame.new(Vector3.new(), Camera.CFrame.RightVector) -- TODO: Why it rotate camera??
+ Vector3.new(
math.clamp(CameraPosition.X, MinCorner.X, MaxCorner.X),
math.clamp(CameraPosition.Y, MinCorner.Y, MaxCorner.Y),
math.clamp(CameraPosition.Z, MinCorner.Z, MaxCorner.Z)
)
end)

What do you mean by this? If I set it to LookVector it doesn’t glitch out, but I’m trying to find the correct vector to use, as the camera for some reason flips when its reached its destination

What he means is that first store the Camera.CFrame.RightVector in a variable outside of the RenderStepped function. Then when you disconnect or you’re done with it, just set it to the stored variable.

CFrame.RightVector is not a constant value. it changes every time RenderStepped runs. each frame it will point to the right of the camera. The version of CFrame.new() you use takes two parameters. 1. a position and 2. a point in space to look at. what you do is each frame you set the cframe to the position (0,0,0), make it look at the RightVector of the camera represented as a Point in space which is why you set the pos to (0,0,0). then you add the original position to return the camera.

tl;dr CFrame.RightVector updates its value every frame