It seems like your script is intended to set the player’s camera mode to first-person view. However, it’s causing an issue where the mouse is locked to the center of the screen. This could be due to the way the camera mode is being changed. Instead of changing the camera mode twice, you can directly set the CameraMode to 1 to achieve the desired effect. Additionally, you can put this code in a UserInputService.InputBegan event to ensure that the camera mode is set correctly without causing the mouse locking issue.
Here’s an updated version of your script:
luaCopy code
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local function setFirstPersonCameraMode()
local localPlayer = Players.LocalPlayer
if localPlayer then
localPlayer.CameraMode = Enum.CameraMode.Classic
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
setFirstPersonCameraMode()
end
end)
This script listens for input events and then sets the camera mode to first-person view. By using the UserInputService.InputBegan event, you ensure that the camera mode is set when the player interacts with the game and avoid any mouse locking issues that might arise from setting the camera mode twice in a short period.
Place this script in StarterPlayerScripts or StarterCharacterScripts as a LocalScript, depending on where you want the camera mode to be set.
is there a way to unlock the mouse as it is stuck in the centre of the screen when in first person. I am try to achieve is having a first person system, but issue is the mouse stops working and won’t move and will stay in the centre of the screen.