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

How to get the player's current viewing mode?

Asked by 10 years ago

Basicly what the the title says, I want to place an object with a surfaceGUI infront of the player when he or she enters Firstpersonmode. I know how to get the player's camera and how to manipulate it, but i couldn't find this feature anywhere.

Thanks in advance!

0
You're not making much sense, but I think you mean Workspace.CurrentCamera.CameraType = "Scriptable" systematicaddict 295 — 10y
0
I feel like im making perfect sense, i just want to know if i can check if a player enters or is in firstperson mode. gamerwies 25 — 10y

2 answers

Log in to vote
1
Answered by
hiccup111 231 Moderation Voter
10 years ago
-- Local Script, within Backpack/PlayerGui

player = game.Players.LocalPlayer
cam = Workspace.CurrentCamera

cam.Changed:connect(function()

    if (cam.CoordinateFrame.p-cam.Focus.p).magnitude < 4 then
        print(player.Name.." is in First Person Mode")
    else
        print(player.Name.." is in Third Person Mode")
    end

end)

If you want to lock the Player's camera into 3rd person, check the settings of the Player:

    print( game.Players.Player.CameraMode )
0
Thank you! this is precisly what i wanted! gamerwies 25 — 10y
Ad
Log in to vote
-1
Answered by
duckwit 1404 Moderation Voter
10 years ago

Use the Changed event on the Camera object to detect when one of it's properties has changed:

previousMode = camera.CameraMode
camera.Changed:connect(function()
    if camera.CameraMode ~= previousMode && camera.CamerMode == "LockFirstPerson" then
        --Display the message
    end
end)

Assuming that you're actually setting LockFirstPerson in the first place, your question is a bit unclear

0
This only gives an output when im forcing a player to go into firstperson, i want to know when a player ENTERS firstperson. gamerwies 25 — 10y
0
Well you shouldn't down vote the answer just because it doesn't suit your precise needs, you didn't specify what you meant in the original post. This even says "assuming you are setting LFP", you should only down vote if it is incorrect/broken - it serves its purpose. duckwit 1404 — 10y

Answer this question