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

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

Asked by
Corogl 0
10 years ago

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

Locked by TheMyrco

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

4 answers

Log in to vote
2
Answered by
nate890 495 Moderation Voter
10 years ago

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.

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. Corogl 0 — 10y
0
Try it now nate890 495 — 10y
1
It works beautifully! Thank you so very much! Corogl 0 — 10y
Ad
Log in to vote
2
Answered by
MunimR 125
10 years ago

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

Log in to vote
0
Answered by 10 years ago

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.

Log in to vote
0
Answered by
Corogl 0
10 years ago

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