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

How to get the player's current viewing mode?

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!

2 comments

0

You're not making much sense, but I think you mean Workspace.CurrentCamera.CameraType = "Scriptable"

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.

2 answers

✓ Accepted answer
-- 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 )

1 comment

0

Thank you! this is precisly what i wanted!

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

2 comments

0

This only gives an output when im forcing a player to go into firstperson, i want to know when a player ENTERS firstperson.

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.

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