Disable Cursor on Zoom into First Person

Is there a way to disable cursor when player is zooming into First Person View?

Yes, you check if the camera is on the player and if the CameraMode is LockFirstPerson or is fully zoomed into player and then set UserInputService.MouseIconEnabled to false. And basically revert said property in the opposite case.

2 Likes

what do you mean by camera on the player? can you give me example?

I believe this will help you: How to Check if a Player is Fully Zoomed in?

Well I don’t have enough time to code a fully optimized script but this LocalScript that you should put into StarterPlayer>StarterPlayerScripts does the job:

local Players = game:GetService("Players")
local lplr = Players.LocalPlayer
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")


runService.RenderStepped:Connect(function()
	local char = lplr.Character or lplr.CharacterAdded:Wait()
	local isFirstPerson = (camera.CFrame.Position - char.Head.Position).magnitude < 1

	if lplr.CameraMode == Enum.CameraMode.LockFirstPerson or isFirstPerson then
		userInputService.MouseIconEnabled = false
	else
		userInputService.MouseIconEnabled = true
	end
end)

The only problem occurs when you are zoomed in and start jumping. The mouse sometimes flashes for a short second. You could try increasing the distance comparsion to 2 studs or something and find the sweet spot to mitigate this issue.
And the only other issue that I can currently think about is Guis that have the property “Modal” set to true. This only is an issue though if you use the CameraMode Enum.CameraMode.LockFirstPerson.

Edit: fixed a little mistake i made in the script

a possible way

--LocalScript
task.wait(2)

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local rns = game:GetService("RunService")
local zoom=nil

rns.RenderStepped:Connect(function()
	zoom = (camera.CFrame.Position - camera.Focus.Position).Magnitude
	uis.MouseIconEnabled = zoom > 1
end)