✓ Accepted answer
Well,
Because you didn't explain what "buggy" means, I'm going to have to assume.
Testing this does exactly what you would expect it to do.
I'm assuming you want it to zoom the camera back out again once you Unequipped the tool. Luckily for you, there's a CameraMinZoomDistance!
Tool = script.Parent
player = game.Players.LocalPlayer
Char = player.Character
Max = player.CameraMaxZoomDistance
Tool.Equipped:connect(function()
player.CameraMaxZoomDistance = 0.5
end)
Tool.Unequipped:connect(function()
player.CameraMaxZoomDistance = Max
player.CameraMinZoomDistance = 12
player.CameraMinZoomDistance = 0.5
end)
Obviously this can be adjusted to not allow the player to zoom in or out as well by Setting camera max and min distance to the same.
Extra info,
You can get where the What the current camera zoom is by finding the magnitude of the Camera Position and the Local Player's Head position, like so,
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:wait()
local Head = char:WaitForChild("Head")
local cam = workspace.CurrentCamera
while wait() do
print((cam.CFrame.p-Head.Position).Magnitude)
end
Good Luck!
I might have misunderstood the question, idk.
2 comments
I'm using it currently for a project and it's not buggy for me. Show us the script that uses Max/Min Camera Zoom and we can help you fix it. I think I might already know the problem, but I need to see the script to be sure.
there