I'm trying to create a third person camera and cannot get it to rotate around the player properly. What I am doing is taking the mouse.Delta as a way to add or subtract the angle of rotation. My problem is it will not rotate around the player, and if I allow the y axis to be rotated, it will be able to be rotated to unusable angles (It can flip upside-down and whatnot) I have tried to add and subtract the Z according to the rotation amount but that probed unreliable. I also tried to use CFrame:toObjectSpace() and couldn't get that to work.
My code:
--Camera update--
game:GetService("RunService").RenderStepped:connect(function()
if player.Self == nil then return end
cam.CoordinateFrame = player.Self.Head.CFrame*CFrame.new(0,1,7)*camera.offset
end)
--Input--
inp.InputChanged:connect(function(io)
if io.UserInputType == Enum.UserInputType.MouseMovement then
camera.offset = camera.offset*CFrame.Angles(0,-math.rad(io.Delta.x/10),0)
end
end)

3 comments
Why don't you NOT use RenderStepped? And what is cam? You haven't named it.
If I didn't use RenderStepped the camera would be laggy as it updated. And I have named it in the code before. cam = player.Camera, player.Camera = game.Workspace.CurrentCamera.
Watch this: https://www.youtube.com/watch?v=kyJZxVJZpHg