local RunService = game:GetService("RunService") local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera -- Force max zoom limits on the engine player.CameraMaxZoomDistance = 99999 player.CameraMinZoomDistance = 0.5 -- UI Setup local ScreenGui = Instance.new("ScreenGui") ScreenGui.Parent = player:WaitForChild("PlayerGui") ScreenGui.ResetOnSpawn = false local ToggleButton = Instance.new("TextButton") ToggleButton.Parent = ScreenGui ToggleButton.Size = UDim2.new(0, 160, 0, 50) ToggleButton.Position = UDim2.new(0.05, 0, 0.4, 0) ToggleButton.BackgroundColor3 = Color3.fromRGB(180, 40, 40) ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) ToggleButton.TextSize = 14 ToggleButton.Font = Enum.Font.SourceSansBold ToggleButton.Text = "Server Cam: LOCKED" local UICorner = Instance.new("UICorner") UICorner.CornerRadius = UDim.new(0, 8) UICorner.Parent = ToggleButton -- DRAGGABLE CODE STRUCTURE local dragging, dragInput, dragStart, startPos local function update(input) local delta = input.Position - dragStart ToggleButton.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y) end ToggleButton.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = true dragStart = input.Position startPos = ToggleButton.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end) end end) ToggleButton.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then dragInput = input end end) UserInputService.InputChanged:Connect(function(input) if input == dragInput and dragging then update(input) end end) -- CAMERA CONTROLS AND ZOOM MATHEMATICS local isOverriding = false local rotX, rotY = 0, 0 local defaultDistance = 15 local connection local activeTouches = {} UserInputService.InputBegan:Connect(function(input, gameProcessed) if not isOverriding or gameProcessed then return end if input.UserInputType == Enum.UserInputType.Touch then activeTouches[input] = input.Position end end) UserInputService.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.Touch then activeTouches[input] = nil end end) UserInputService.InputChanged:Connect(function(input, gameProcessed) if not isOverriding then return end if gameProcessed and input.UserInputType ~= Enum.UserInputType.MouseWheel then return end if input.UserInputType == Enum.UserInputType.MouseWheel then defaultDistance = math.clamp(defaultDistance - (input.Position.Z * 4), 5, 99999) return end local touchCount = 0 local fingers = {} for inp, pos in pairs(activeTouches) do touchCount = touchCount + 1 table.insert(fingers, inp) end -- Mobile Pinch Zoom if touchCount == 2 and input.UserInputType == Enum.UserInputType.Touch then activeTouches[input] = input.Position local f1 = fingers[1].Position local f2 = fingers[2].Position local currentDist = (f1 - f2).Magnitude local p1 = fingers[1].Delta local p2 = fingers[2].Delta local prevDist = ((f1 - p1) - (f2 - p2)).Magnitude local change = currentDist - prevDist defaultDistance = math.clamp(defaultDistance - (change * 0.15), 5, 99999) -- Drag to look elseif touchCount <= 1 and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then -- This logic ignores input adjustments if you are dragging the UI button itself if dragging then return end rotX = rotX - input.Delta.X * 0.4 rotY = math.clamp(rotY - input.Delta.Y * 0.4, -75, 75) end end) local function startCameraOverride() connection = RunService.RenderStepped:Connect(function() if isOverriding then camera.CameraType = Enum.CameraType.Scriptable local target = player.Character and player.Character:FindFirstChild("HumanoidRootPart") if not target then return end local seat = player.Character.Humanoid.SeatPart if seat and seat.Parent then target = seat.Parent.PrimaryPart or seat end local startCFrame = CFrame.new(target.Position) local rotationCFrame = CFrame.Angles(0, math.rad(rotX), 0) * CFrame.Angles(math.rad(rotY), 0, 0) camera.CFrame = startCFrame * rotationCFrame * CFrame.new(0, 2, defaultDistance) end end) end ToggleButton.MouseButton1Click:Connect(function() -- Only toggle if we weren't just dragging the button across the screen if dragging then return end isOverriding = not isOverriding table.clear(activeTouches) if isOverriding then ToggleButton.Text = "Server Cam: OVERRIDDEN" ToggleButton.BackgroundColor3 = Color3.fromRGB(0, 150, 70) local _, y, _ = camera.CFrame:ToOrientation() rotX = math.deg(y) rotY = 0 else ToggleButton.Text = "Server Cam: LOCKED" ToggleButton.BackgroundColor3 = Color3.fromRGB(180, 40, 40) camera.CameraType = Enum.CameraType.Custom if player.Character and player.Character:FindFirstChild("Humanoid") then camera.CameraSubject = player.Character.Humanoid end end end) startCameraOverride()