How do I limit the camera viewing/scroll distance of the player's camera?

Someone has probably already asked this before but when I look it up it’s just that one glitch with the screen scroll

Basically I want to prevent my players from scrolling outward so far and being able to see so much, I only want them to be able to see within my boundaries. How can I do this?

Player.CameraMaxZoomZoomDistance is probably what you’re looking for.

1 Like


In starterplayerscripts

The code

game.Players.LocalPlayer.CameraMinZoomDistance = 2
game.Players.LocalPlayer.CameraMaxZoomDistance = 2

clearly it didn’t really do anything…?

Placing it in StarterCharacterScripts fixes it. I’m not quite sure why it doesn’t work in StarterPlayerScripts. It may have something to do with how Roblox handles script and character loading, but I’d have to investigate.

Edit: After a cursory look at the StarterPlayerScripts documentation, it seems my suspicion was correct, but I’m still not sure why. LocalScripts in StaterPlayerScripts are ran as soon as the player joins the game, which results may the code executing before the player can exist.

But even if that is the case, it does not explain why the script does not error. If it is ran before the player exists, attempting to modify the non-existent LocalPlayer should error. I’m not sure if this is a bug or an intended behavior. There are several ways to circumvent this issue, so I’m not going to look into it more. But if you or anyone else is interested in investigating further, I invite you to do so, as this is very interesting.