CameraZoomDistance not functioning correctly?

Basically, I have a first person game, with a spectating function. Once you press the spectate button, your cameramax and min zoom distance changes to 10. Once you close it, a remoteevent fires and it returns to 0.5 on both.

Script:

game.ReplicatedStorage.Events.SpectateEvent.OnServerEvent:Connect(function(plr)
	print("e")
	plr.CameraMaxZoomDistance = 0.5
	plr.CameraMinZoomDistance = 0.5
end)

It does in fact print, so it does not have to do with the event itself.

(what’s weird is that the zoomdistance can only change once for some reason which is what i’m trying to fix)

3 Likes

Do it in a Local Script, you dont need to fire a remote to the server to change the CameraZoom of a client. And make sure you are not Incrementing the Min value before Reducing the Max value. Otherwise you are telling to the engine to have a Min of 10 when your current Max is 0.5. So it gets ignored.

Quick silly script you can place in a local script in your player:

local localPlr = game.Players.LocalPlayer

local inOut = false

script.Parent:WaitForChild("TextButton").Activated:Connect(function()
	inOut = not inOut
	if inOut then
		localPlr.CameraMaxZoomDistance = 11
		localPlr.CameraMinZoomDistance = 10
	else
		localPlr.CameraMinZoomDistance = 0.5
		localPlr.CameraMaxZoomDistance = 0.6
	end
end)
1 Like

Did you know?

In StarterPlayer, there is a property called “CameraMode” which is usually set to default but you could set it to “LockFirstPerson” to make an FPS camera? Without setting CameraMinZoomDistance? Now you can just set your Camera(Min/Max)ZoomDistance to whatever you want and just toggle between “Default” and “LockFirstPerson”. It’s that simple!

1 Like