Camera CFraming

I’m sure this is a fairly simple one but for whatever reason I can’t find the answer. I would appreciate it if someone could help me find some code that does these things:

  1. Camera faces the player from the front no matter what direction the player faces. (Not a loop)
  2. Camera is situated a few studs away from the character so you can view the whole character.
  3. Camera is a few studs to the left of the character so the character is on the left side of the screen.

If this doensn’t make a lot of sense let me know.

It is pretty simple, you can check the CFrame guide at Roblox documentation to figure out how to make a camera script that does these tasks for you, here’s the link: CFrames | Roblox Creator Documentation

If you’re asking for code done by other person, sadly I can’t help you, the best I can do is to provide pseudocode:

playerHead = player.Character.Head
camera = workspace.CurrentCamera

  camera.CFrame = -- do cframe stuff that you learned in the docs

This doesn’t help me. The code you provided contains something I asked not to be in it, and I know how to CFrame. For some reason it just isn’t working for me. Ill provide the code I have so far.

local offsetcframe =,0,6) * CFrame.Angles(0, math.rad(-180), 0)
Camera.CFrame = Character.PrimaryPart.CFrame:ToWorldSpace(offsetcframe)

This code may look poorly cuz I’m writing it in the post thing

local playerHead = character.Head

camera.CameraType = Enum.CameraType.Scriptable --// Allow us to set the CFrame of the Camera

local flipYAxis = CFrame.fromAxisAngle(Vector3.yAxis, math.pi * 2)
local targetCFrame = playerHead.CFrame *, 0, -10) * flipYAxis

camera.CFrame = targetCFrame

If it turns out that the player is on the right of the screen then just change -5 to 5

I don’t think it’s possible to do what you want here without a RenderStepped loop/connection.

This is pretty cool.

Put This Inside StarterCharacterScripts (654 Bytes)

You’ll have to code the camera controls (like zooming in and out) alongside this though, which is annoying.

Works really nicely thanks. And I wasn’t really clear enough, I intend it to be a button you click, it changes the camera and freezes your character, click the button again and it resets it, I just removed the loop, Thanks a lot :grinning:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.