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.
maybe this script works
btw this is the full script replace it
local UserInputService = game:GetService(“UserInputService”)
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
– Lock the camera to first person
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) – Adjust the offset as needed
– Store the initial mouse position
local initialMousePosition = UserInputService:GetMouseLocation()
– Function to update camera rotation based on mouse movement
local function UpdateCameraRotation()
local currentMousePosition = UserInputService:GetMouseLocation()
local deltaMouse = currentMousePosition - initialMousePosition
local rotationY = deltaMouse.X / 100 -- Adjust the sensitivity as needed
local rotationX = deltaMouse.Y / 100
local currentRotation = camera.CFrame:ToEulerAnglesYXZ()
local newYRotation = currentRotation.Y + rotationY
local newXRotation = math.clamp(currentRotation.X - rotationX, -math.pi/2, math.pi/2)
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(0, newYRotation, 0) * CFrame.Angles(newXRotation, 0, 0)
initialMousePosition = currentMousePosition
end
– Connect the function to the mouse movement event
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
UpdateCameraRotation()
end
end)