Still have questions? Join our Discord server and get real time help.
6

# How do I force first-person mode? [closed]

I've seen some games on ROBLOX force first-person camera so you can't zoom out. How can I do this in my game?

### Locked by evaera

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

4
Unclear 1776
6 years ago

ROBLOX has a neat property in the Player object called CameraMode. This property holds an Enum value, which can be either Classic (which is the typical default setting) or LockFirstPerson.

You can use LockFirstPerson to force this sort of lock.

Here's an example code that would go in a regular Script...

game.Players.PlayerAdded:connect(function(player)
player.CameraMode = "LockFirstPerson"
end)

12
Please don’t use a string where enum items are expected. Use Enum.CameraMode.LockFirstPerson instead of "LockFirstPerson". MarkOtaris 241 — 6y
-1

first of all you can't just lockfirstperson and put report or while loop it'll only work once to correct this error you would have to do something like this

player = game.Players.LocalPlayer
while true do
wait(0)--change this to whatever you want
player.CameraMode = Enum.CameraMode.Classic
Player.CamerMode =  Enum.CameraMode.LockFirstPerson
end

0
sorry i meant repeat not report sorry mikeinator3214 0 — 6y
-2
Uroxus 350
6 years ago

There is a lot simpler way of just making them first person as soon as they spawn, if you want this then:

repeat wait() until game.Players.LocalPlayer
local p = game.Players.LocalPlayer
p.CameraMode = "LockFirstPerson"


Hope this helps.

-2

Well, I won't give you the direct code, as I think that if you learn it on your own it will stick better in your brain than if I just give you it. I would suggest going to... 1) http://wiki.roblox.com/index.php?title=CameraMode_(Property) 2)http://wiki.roblox.com/index.php?title=CameraMode_(Enum)

But there are a couple other ways, but remember, some ways require local scripts and some don't. Well I hope I helped! ~Georgeba, Roblox

-3

Make a GUI that says something like this: "Click here to play" and when its clicked, make it run this

script.Parent.MouseButton1Down:connect(function()
local fps = game.Lighting.fpsScript:clone()
fps.Parent=game.Players.LocalPlayer -- if localScript
--elseif not local script then
--fps.Parent=script.Parent until it reaches your player
fps.Disabled = false
-- how I did mine: http://www.roblox.com/Weld-Testing-place?id=153151316
-- it adds a sword script where you can swing your sword without a hopperbin or tool and its broken ATM
end)

-3

you can lock first person mode by inserting a script which is

while true do
wait()
local c = workspace:GetChildren()
for i=1, #c do
if c[i].className == "Camera" and (c[i].CoordinateFrame.p - c[i].Focus.p).magnitude > 40 then
c[i].CoordinateFrame = c[i].CoordinateFrame * CFrame.new((CFrame.new(c[i].CoordinateFrame.p, c[i].Focus.p)).lookVector * (c[i].CoordinateFrame.p - c[i].Focus.p).magnitude)
end
end
end



or you can do a command to lock and unlock first person view by inserting a script and typing

function onPlayerSpawned(player, character)
player.CameraMode = "LockFirstPerson"
end

function onPlayerChatted(player, message, recipient)
if player.userId == game.CreatorId and game.CreatorType == Enum.CreatorType.User then
if message == "/thirdperson" then
player.CameraMode = "Classic"
elseif message == "/firstperson" then
player.CameraMode = "LockFirstPerson"
end
end
end

function onPlayerEntered(player)
player.Chatted:connect(function (msg, rec) onPlayerChatted(player, msg, rec) end)

player.CameraMode = "LockFirstPerson"
end



hope it helps :)

-3
script.Parent.Parent.CameraMode="LockFirstPerson"