unity make camera fsp code example

Example: how to disable camera zooming in roblox

local player = game.Players.LocalPlayer -- Get the player (for the camera)
local currentZoom = (workspace.CurrentCamera.CoordinateFrame.p - player.Character.Head.Position).magnitude (calc. currentzoom)
local LastMaxZoom = player.CameraMaxZoomDistance -- save the current settings
local LastMinZoom = player.CameraMinZoomDistance  -- ^

local isDisabled = false
function ToggleScroll() -- simple on/off function for the zoomies
    if isDisabled then -- Scroll is active
        isDisabled = false
        player.CameraMaxZoomDistance = LastMaxZoom
        player.CameraMinZoomDistance = LastMinZoom
    else -- scroll is inactive
        isDisabled = true
        player.CameraMaxZoomDistance = currentZoom
        player.CameraMinZoomDistance = currentZoom
    end
end

Tags:

Lua Example