How to manually set camera zoom level with a scriptable camera

Hey there Support, I’m trying to design a camera system for my top-down roguelite, cross platform between all platforms.

I’m having an issue where using the function Camera:Zoom(zoomvalue) [referencing the devwiki: Camera] is returning the following error:
(note - this function is bound via contextactionservice)

ContextActionService: Unexpected error while invoking callback: The current identity (2) cannot Zoom (lacking permission 5)  -  Studio

here is my code for reference:

local function changeZoomLevel(x, y, z)
	if character == nil then return end
	if y == Enum.UserInputState.End then
	if y == Enum.UserInputState.Begin then
		if zoomLevel == 1 then
			zoomLevel = 2
		elseif zoomLevel == 2 then
			zoomLevel = 3
		elseif zoomLevel == 3 then
			zoomLevel = 1
			zoomLevel = 1

Now at the end of the day I hate having to make a button for zoom and to set the camera to scriptable, however I cannot prevent the player from looking around while still retaining the zoom features on Xbox and Mobile. I’m currently testing to see if using ContextActionService to bind up controller zoom button and mobile dragging is worth it instead, however if there are any other ways to fix this error I would appreciate the advice.


Howdy, your issue is that :Zoom() can only be accessed by CoreUI. You can find the documentation here.

If I am to take you on a hunch, are you attempting to change the players Field of View (FOV)? If so, you can simply replace the following;

Camera:Zoom(45) -- to,

Camera.FieldOfView = 45

You can find the documentation for FieldOfView here, and documentation for Camera here.

1 Like

Thank you very much! Unfortunately I’m not trying to change FOV as this warps the view, however knowing that zoom is protected answers the question completely. my only option now is lock the camera scriptable and change the coordinateframe to farther away values, unfortunately as my tests with contextactionservice are easily bypassed by rebinding controls. Thanks for the answer!

1 Like