First-Person Camera Script

Hey Developers!

(Some context before I start yapping, I DO NOT KNOW HOW TO PROGRAM, this is what Roblox’s Assistant is giving me.)

I’m encountering a simple issue. I’m trying to make a game where you play from the perspective of your “officer’s” body camera. This is the code:

(I know, light theme, I wanted to shake things up today. Sue me.)
(also I know the Y value is 5, I was trying to see if it was working earlier. Spoiler alert: it didn’t.)

It’s not working, it’s supposed to make the first-person camera lower at all times, and it just does a buncha big fat nothing! Mind helping me out here?


You need to set the cameraType to “Scriptable” first and I’d recommend setting the cameraSubject to your “body camera” as seen in the following code:

local bodyCam = -- body cam
local camera = workspace.CurrentCamera

camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = bodyCam
camera.CFrame = bodyCam.CFrame

If you would like to set it back, just change the “camera.CameraType” to Custom.

Still a negative, holmes. Am I doing something wrong?

1 Like

Update the camera according to the character’s position and wrap it in renderStepped.

1 Like

I will explain to you why your code doesn’t work.

It is set only once. The camera needs to be updated every frame. As such, you’d need to place your code into a loop. (so it keeps running indefinitely, over and over again, every frame)

Make sure your variables, i.e bodyCam are properly defined. (so the game knows exactly which object to use)

local runservice = game:GetService('RunService')

    camera.CFrame = bodyCam.CFrame --*,0,0) incase you want to offset it.

1 Like

You can change the players humanoid camera offset

1 Like

Thank you guys, I’m going to make another topic on this because Roblox decided to break and all of my scripts were screwed and they worked alright beforehand. Once again thanks for the help.

Waitwaitwait, what?

Elaborate real fast… this might fix it.

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