I made this script that locks the player's cam distance to 10 which is only to avoid zooming in and out by accident. How can I make it so when the player clicks again, it lets him/her use the scrolling to zoom in and out?
1 | local player = game.Players.LocalPlayer |
2 |
3 | script.Parent.MouseButton 1 Click:Connect( function (click) |
4 | player.CameraMaxZoomDistance = 10 |
5 | end ) |
You could set a variable defining if it was enabled or not, and change that based on the player click. Example:
01 | local player = game.Players.LocalPlayer |
02 | local locked = false |
03 |
04 | script.Parent.MouseButton 1 Click:Connect( function (click) |
05 | if locked = = false then |
06 | player.CameraMaxZoomDistance = 10 |
07 | locked = true |
08 | elseif locked = = true then |
09 | player.CameraMaxZoomDistance = 128 -- This is game default, set this to whatever you want |
10 | locked = false |
11 | end |
12 | end ) |