I don't know how to detect when the player is fully zoomed in

  1. What do you want to achieve?
    I am attempting to make a camera system like Centura (see attached video below). There are different camera positions, I have offset the camera to match these positions. I need to know how to detect when the player is fully zoomed in so I can make them enter first person. I am a rookie to scripting and any help is much appreciated. Thanks. PLEASE TELL ME IF ANYTHING IS UNCLEAR, I will gladly elaborate, I wrote this 10 minutes before I went to bed

  1. What is the issue?
    My issue is that I can not detect when the player is fully zoomed in.

  2. What solutions have you tried so far?
    I have tried searching for solutions on Forums with no luck. I believe that the offset is interfering with the detection. I have also tried putting parts to detect when the player zooms in on them, however, it does not work very well because when the player rapidly rotates the camera, it dips out of the parts(look at the pauses in the output). If I make the parts too large, they can partially zoom in and see the first person effect while being in third person (Centura also experiences an issue like this, see second attached video). This is also because the parts aren’t in the same position as the offset, they are slightly misaligned, I tried to make up for it by making the parts larger but this too, did not work. I do not know how to set the offset to the parts position, I have tried to look for solutions, the things that I tried did not work at all. See attached video for what I currently have.

this is the zooming in on parts code

local function checkifzoomedin() --selected cams are the cam parts
	if (left.Position-camera.CFrame.Position).Magnitude < 1 and selectedcam2 == false and selectedcam3 == false then
		print("true")
		return true
	elseif (middle.Position-camera.CFrame.Position).Magnitude < 1 and selectedcam3 == false and selectedcam1 == false then
		print("true")
		return true
	elseif (right.Position-camera.CFrame.Position).Magnitude < 1 and selectedcam1 == false and selectedcam2 == false then
		print("true")
		return true
	end

end

local readytoenterfirst = false -- if the player is zoomed in on the parts


game:GetService("RunService").RenderStepped:Connect(function()

		checkifzoomedin()

		if checkifzoomedin() == true then
			fullzoom = true -- if the player is zoomed in on the parts
			readytoenterfirst = true
		else
			fullzoom = false
			readytoenterfirst = false
		end
end)

Thank you!!

Local script, inside StarterPlayerScripts

local run = game:GetService("RunService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local camera = workspace.CurrentCamera

run.RenderStepped:Connect(function()
	local distance = (head.Position - camera.CFrame.Position).Magnitude
	if distance < 1 then
		print("Player's camera is zoomed in.")
	else
		print("Player's camera is zoomed out.")
	end
end)

or more reliable, check the LocalTransparencyModifier of the head

1 Like

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