Trying to lock the player into first person once the game starts

I’m working on a horror game based on the backrooms. I have the player’s camera set to third person so they can move their mouse around and press GUI buttons. I’m trying to set their camera to first person once the game starts, but any changes I make aren’t happening.

This is the script I’m currently using. It’s a local script.

local Button = game.Players.LocalPlayer.PlayerGui.ScreenGui.OptionYes
local frame = script.Parent
local Audio = game.SoundService.RustyDoor

local function StartNewGame()
	game.StarterPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
	game.StarterPlayer.CameraMinZoomDistance = 0.5
	task.wait(30)
	frame.Transparency = 0
	Audio:Play()
	task.wait(6)
	for i = 1, 100, 1 do
		frame.Transparency += 0.01
		task.wait(0.01)
	end
end

Button.MouseButton1Click:Connect(StartNewGame)

I’ve found other topics on this, but they’re confusing and don’t seem to have clear answers.

1 Like

You’re using the StarterPlayer instance, instead of the actual player’s camera. Change that to workspace.CurrentCamera instead.

1 Like

That didn’t work. I changed the script to this:

local Button = game.Players.LocalPlayer.PlayerGui.ScreenGui.OptionYes
local frame = script.Parent
local Audio = game.SoundService.RustyDoor
local camera = workspace.CurrentCamera

local function StartNewGame()
	camera.CameraMode = Enum.CameraMode.LockFirstPerson
	camera.CameraMinZoomDistance = 0.5
	task.wait(30)
	frame.Transparency = 0
	Audio:Play()
	task.wait(6)
	for i = 1, 100, 1 do
		frame.Transparency += 0.01
		task.wait(0.01)
	end
end

Button.MouseButton1Click:Connect(StartNewGame)

Try changing the CameraType to Scriptable first before setting the CameraMode?

1 Like

Still doesn’t work. If I do that, the player’s camera becomes fixed and is unable to move.

You can just script the CameraType back to Custom after locking it. Does the Camera at least go into FirstPerson after you made it Scriptable?

1 Like

If you just want to unlock the mouse in first person for x amount of time or for gui then you can do so without changing the camera. Check out these posts:

1 Like

It doesn’t. The camera position is set to the first position it’s in when it’s set to scriptable.

I believe you might want to try setting the player’s CameraMaxZoomDistance property to 0.5 instead of CameraMinZoomDistance

1 Like

Although this is already solved, that wouldn’t have worked. No changes were being done. I tried to set the minimum zoom distance to 0.5, but it remained at it’s original value of 5.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.