How do i do it ? i have no idea if i do the minzoomdistance in player and max it will make it very buggy so what's the other way ?
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 end)
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.
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 Script 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)-- Prints current Camera Zoom Distance end
Good Luck!