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

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

Asked by 11 years ago

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?

0
All you have to put in is 1 script.Parent.Parent.CameraMode="LockFirstPerson" Arratic -5 — 10y
0
All you have to put in is 1 script.Parent.Parent.CameraMode="LockFirstPerson" Arratic -5 — 10y

Locked by evaera

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

Why was this question closed?

7 answers

Log in to vote
4
Answered by
Unclear 1776 Moderation Voter
11 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...

1game.Players.PlayerAdded:connect(function(player)
2    player.CameraMode = "LockFirstPerson"
3end)
12
Please don’t use a string where enum items are expected. Use Enum.CameraMode.LockFirstPerson instead of "LockFirstPerson". MarkOtaris 241 — 11y
Ad
Log in to vote
-1
Answered by 10 years ago

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

1player = game.Players.LocalPlayer
2while true do
3wait(0)--change this to whatever you want
4player.CameraMode = Enum.CameraMode.Classic
5Player.CamerMode =  Enum.CameraMode.LockFirstPerson
6end
0
sorry i meant repeat not report sorry mikeinator3214 0 — 10y
Log in to vote
-2
Answered by
Uroxus 350 Moderation Voter
10 years ago

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

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

Hope this helps.

Log in to vote
-2
Answered by 10 years ago

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

Log in to vote
-3
Answered by 10 years ago

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

1script.Parent.MouseButton1Down:connect(function()
2local fps = game.Lighting.fpsScript:clone()
3fps.Parent=game.Players.LocalPlayer -- if localScript
4--elseif not local script then
5--fps.Parent=script.Parent until it reaches your player
6fps.Disabled = false
8-- it adds a sword script where you can swing your sword without a hopperbin or tool and its broken ATM
9end)
Log in to vote
-3
Answered by 10 years ago

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

1while true do
2    wait()
3    local c = workspace:GetChildren()
4    for i=1, #c do
5        if c[i].className == "Camera" and (c[i].CoordinateFrame.p - c[i].Focus.p).magnitude > 40 then
6            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)
7        end
8    end
9end

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

01function onPlayerSpawned(player, character)
02    player.CameraMode = "LockFirstPerson"
03end
04 
05function onPlayerChatted(player, message, recipient)
06    if player.userId == game.CreatorId and game.CreatorType == Enum.CreatorType.User then
07        if message == "/thirdperson" then
08            player.CameraMode = "Classic"
09        elseif message == "/firstperson" then
10            player.CameraMode = "LockFirstPerson"
11        end
12    end
13end
14 
15function onPlayerEntered(player)
View all 22 lines...

hope it helps :)

Log in to vote
-3
Answered by 10 years ago

all you have to type is

1script.Parent.Parent.CameraMode="LockFirstPerson"

and that's it 1 line is enough, I tried it, it worked for me :p