How to make a fixed first person camera

I am trying to code a first person camera that cannot be moved (Holding right click to move camera), but I cannot figure out how to make a script that does that. I already have a first person script, but I am not sure if you can disable camera movement without changing the camera type to scriptable.
I have found many scripts online, but none of them could be edited to work in first person.
All help is appreciated!
Edit: I also have Modal enabled so the player can click around the screen.

local script inside startergui:

repeat
    task.wait()
until nil ~= game.Players.LocalPlayer.Character --yields until character loads

local rs = game:GetService("RunService")
local cam = workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character

cam.CameraType = Enum.CameraType.Scriptable

rs.RenderStepped:Connect(function()
    if character then --if the character isn't nil
        cam.CFrame = character.Head.CFrame --sets the cframe of the camera to the head of the player's cframe
    end
end)
1 Like

When I joined the game, the camera started spinning around rapidly. There were no errors in the output. Not sure if this has anything to do with it, but the game is forced in R6.

are there any other scripts interfering with the camera?

There was, but I removed it and nothing changed.

do you have a video i can see?

I would show you a video, but I cant find any way to post a video that doesnt pass the file size limit. Sorry!

I’m going to try and attach the camera to a part on the players head and see if that works.

Edit: Same Visual glitch happened, even with the part. Although if you look at the glitch from the server while testing it looks pretty funny.

1 Like

Again, what do you want to do, so that player cannot look around in first person ?

I want to have the player locked in first person, and I don’t want them to be able to move the camera (Such as holding right click and moving your mouse, or pressing left and right arrow keys).

Well, I don’t know exactly what you want, maybe Im just too tired to understand right now, but I made first person mode recently. You can check it out and hopefully it will help you. It works with R6 and R15 and includes player body and neck rotation, but you are locked in first person.

1 Like

Don’t get me wrong, this is great, but it doesn’t achieve exactly what I wanted.

And what did you want, if you tell me I could try to modify the script for your needs. Try explaining it more or show me screenshot/video of how it should look like.

Not exactly sure but try disabling autorotate of the humanoid

I’m not sure what happened, but when I reopened studio after eating lunch this script worked. I didn’t make any changes, so my guess is that studio glitched somehow. Thanks everyone who helped here!

2 Likes