Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How you Lock FirstPerson camera?

Asked by 10 years ago

I know this is part of it:

for i,v in pairs(game.Players:GetPlayers()) do v.CameraMode = "LockFirstPerson" end

but i don't know if it's wrong i tried to fix it but it still wrong can someone tell me if it's wrong or it miss something more please.

2 answers

Log in to vote
2
Answered by
c0des 207 Moderation Voter
10 years ago

Put this in a LocalScript:

game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
Ad
Log in to vote
1
Answered by
m0rgoth 75
10 years ago

As c0des mentioned already, you should do something like this:

game.Players.LocalPlayer.CameraMode = "LockFirstPerson"

I wanted to point a few other things out though. First of all, you can shorten that statement down to what I have above. There are 2 differences in it:

I just get the 'Players' service as a child of 'game' rather than getting the service which does the same thing but takes more code and is annoying to type.

I used a string with the name of the enum value rather than the full enum statement to get the camera mode enum.

Secondly, you need to make sure, as he stated that this code is placed in a LocalScript, but also make sure that you put the LocalScript into the player's backpack, playergui, or character or it will not run.

Lastly, if you are leaving the script inside of the StarterGui or StarterPack, you will have to change the code to this:

game.Players.LocalPlayer.CameraMode = "Classic"
game.Players.LocalPlayer.CameraMode = "LockFirstPerson"

This is due to a quirk with the ROBLOX system and I am not actually sure why it is a problem, but you will find that without this when the player spawns for the first time their camera mode will change, but whenever they die, the camera will not be locked to first person and will remain in the classic mode. This seems to reset the camera and ensures that you will always end up in first person.

Answer this question