Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The following "First Person Only" script does not work. [SOLVED]

This script, when placed in a Script and then placed in ServerScriptService does not work. I am confused whether or not I need a LocalScript and where it should be going. If this is the correct place/object, what is wrong with the script? I would like it to force the player into 1st person but not by using a GUI that blocks view when zooming out.

while true do
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson 
wait(10)
end

4 answers

✓ Accepted answer

As stated by Fattycat, it should indeed be ran through a localscript, otherwise it will only work in solo mode. However, earlier I was playing with CameraMode (see this thread) and came across a very unique problem- the CameraMode didn't want to change when the code was ran for the second time (only successfully changing the CameraMode when the player joined, not upon reset.)

This being said, there is a solution to this rather annoying CameraMode issue, and the solution was posted on the thread that I linked earler (it's the last post on the thread.) The solution is to simply change the CameraMode value to "Classic" and then to "LockFirstPerson."

If you want to force first person upon entering and resetting, put the following code in a LocalScript and insert the LocalScript into game.StarterPack or game.StarterGui.

local player = game.Players.LocalPlayer

player.CameraMode = Enum.CameraMode.Classic
wait() -- I don't know if this wait is needed, I haven't tested it, but the person who supplied a solution included a wait (again, see the link posted earlier in this answer)
player.CameraMode = Enum.CameraMode.LockFirstPerson

Hope this helps. Feel free to leave a comment if it didn't.

3 comments

0

Unfortunately, this script did not seem to work. Tried with the local script in both starterpack and startergui, but it did not make any difference.

0

Try it now

1

It works beautifully! Thank you so very much!

Make sure you put this in a Local Script, since you reference "LocalPlayer" and place into the Player somehow (Easiest method is StarterGui)

Fatty cat already got it down. It's being used for a player, so use local script to allow access of first person only for the player. What you have is right, but use it as local script.

Vote this if it was useful.

I want to thank you guys for the responses, although neither of these seemed to work.

This discussion is preserved as it was. New answers, comments, and votes are closed.