Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Function to check if a player has zoomed in?

**Do I have to use coordinate frame of some sort? **

plr = game.Players.LocalPlayer
ZoomedIn = false

--{{Some Camera Function}}
ZoomedIn = true
print(plr.Name.." has zoomed in.")






--{{end}}


1 answer

You can get the distance between the Camera and the Character's Head, which should be 0 if they are fully zoomed in:

plr = game.Players.LocalPlayer
ZoomedIn = false
local camera = workspace.CurrentCamera

camera.Changed:connect(function() --probably a better event to connect to than this, but this should work.
	if (camera.CoordinateFrame.p - plr.Character.Head.CFrame.p).magnitude <= .5 then
		ZoomedIn = true
		print(plr.Name.." has zoomed in.")
	else
		ZoomedIn = false
		print(plr.Name .. " is not zoomed in.")
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.