local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local RunService = game:GetService("RunService") local TweenService = game:GetService("TweenService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local playerGui = player:WaitForChild("PlayerGui") local lockedTarget = nil local lockEnabled = false local systemEnabled = true local maxDistance = 120 local keybind = Enum.KeyCode.X local waitingForKeybind = false local function getPart(character, name) if character then return character:FindFirstChild(name) end end local function validTarget(other) if other == player then return false end local char = other.Character if not char then return false end local hum = char:FindFirstChildOfClass("Humanoid") local head = getPart(char, "Head") local root = getPart(char, "HumanoidRootPart") if not hum or hum.Health <= 0 then return false end if not head or not root then return false end local myChar = player.Character local myRoot = myChar and getPart(myChar, "HumanoidRootPart") if not myRoot then return false end local dist = (root.Position - myRoot.Position).Magnitude return dist <= maxDistance end local function closestTarget() local best = nil local bestDist = math.huge local center = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2) for _, p in ipairs(Players:GetPlayers()) do if validTarget(p) then local head = getPart(p.Character, "Head") local pos, visible = camera:WorldToViewportPoint(head.Position) if visible then local screenPos = Vector2.new(pos.X, pos.Y) local d = (screenPos - center).Magnitude if d < bestDist then bestDist = d best = p end end end end return best end -- GUI local gui = Instance.new("ScreenGui") gui.Name = "ModernCamLockUI" gui.ResetOnSpawn = false gui.Parent = playerGui local main = Instance.new("Frame") main.Name = "Main" main.Size = UDim2.new(0, 300, 0, 170) main.Position = UDim2.new(0, 25, 0.5, -85) main.BackgroundColor3 = Color3.fromRGB(12, 14, 28) main.BorderSizePixel = 0 main.ZIndex = 1 main.Parent = gui local mainCorner = Instance.new("UICorner") mainCorner.CornerRadius = UDim.new(0, 18) mainCorner.Parent = main local stroke = Instance.new("UIStroke") stroke.Color = Color3.fromRGB(65, 115, 255) stroke.Thickness = 2 stroke.Transparency = 0 stroke.Parent = main local topBar = Instance.new("Frame") topBar.Name = "TopBar" topBar.Size = UDim2.new(1, 0, 0, 40) topBar.BackgroundColor3 = Color3.fromRGB(18, 22, 40) topBar.BorderSizePixel = 0 topBar.ZIndex = 2 topBar.Parent = main local topCorner = Instance.new("UICorner") topCorner.CornerRadius = UDim.new(0, 18) topCorner.Parent = topBar local topFill = Instance.new("Frame") topFill.Size = UDim2.new(1, 0, 0, 18) topFill.Position = UDim2.new(0, 0, 1, -18) topFill.BackgroundColor3 = Color3.fromRGB(18, 22, 40) topFill.BorderSizePixel = 0 topFill.ZIndex = 2 topFill.Parent = topBar local accent = Instance.new("Frame") accent.Size = UDim2.new(1, 0, 0, 2) accent.Position = UDim2.new(0, 0, 0, 40) accent.BackgroundColor3 = Color3.fromRGB(65, 115, 255) accent.BorderSizePixel = 0 accent.ZIndex = 2 accent.Parent = main local title = Instance.new("TextLabel") title.Size = UDim2.new(1, -20, 0, 24) title.Position = UDim2.new(0, 14, 0, 8) title.BackgroundTransparency = 1 title.Text = "Cam Lock Panel" title.TextColor3 = Color3.fromRGB(245, 247, 255) title.TextXAlignment = Enum.TextXAlignment.Left title.Font = Enum.Font.GothamBold title.TextSize = 17 title.ZIndex = 3 title.Parent = main local subtitle = Instance.new("TextLabel") subtitle.Size = UDim2.new(1, -28, 0, 18) subtitle.Position = UDim2.new(0, 14, 0, 54) subtitle.BackgroundTransparency = 1 subtitle.Text = "Press chosen key to lock to nearest head" subtitle.TextColor3 = Color3.fromRGB(150, 160, 190) subtitle.TextXAlignment = Enum.TextXAlignment.Left subtitle.Font = Enum.Font.Gotham subtitle.TextSize = 12 subtitle.ZIndex = 3 subtitle.Parent = main local status = Instance.new("TextLabel") status.Size = UDim2.new(1, -28, 0, 20) status.Position = UDim2.new(0, 14, 0, 82) status.BackgroundTransparency = 1 status.Text = "Status: Enabled" status.TextColor3 = Color3.fromRGB(90, 255, 140) status.TextXAlignment = Enum.TextXAlignment.Left status.Font = Enum.Font.GothamMedium status.TextSize = 14 status.ZIndex = 3 status.Parent = main local targetLabel = Instance.new("TextLabel") targetLabel.Size = UDim2.new(1, -28, 0, 20) targetLabel.Position = UDim2.new(0, 14, 0, 106) targetLabel.BackgroundTransparency = 1 targetLabel.Text = "Target: None" targetLabel.TextColor3 = Color3.fromRGB(215, 220, 235) targetLabel.TextXAlignment = Enum.TextXAlignment.Left targetLabel.Font = Enum.Font.Gotham targetLabel.TextSize = 14 targetLabel.ZIndex = 3 targetLabel.Parent = main local toggleButton = Instance.new("TextButton") toggleButton.Size = UDim2.new(0, 105, 0, 34) toggleButton.Position = UDim2.new(1, -119, 1, -48) toggleButton.BackgroundColor3 = Color3.fromRGB(65, 115, 255) toggleButton.BorderSizePixel = 0 toggleButton.Text = "ON" toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) toggleButton.Font = Enum.Font.GothamBold toggleButton.TextSize = 14 toggleButton.AutoButtonColor = false toggleButton.ZIndex = 3 toggleButton.Parent = main local buttonCorner = Instance.new("UICorner") buttonCorner.CornerRadius = UDim.new(0, 10) buttonCorner.Parent = toggleButton local buttonStroke = Instance.new("UIStroke") buttonStroke.Color = Color3.fromRGB(150, 185, 255) buttonStroke.Thickness = 1 buttonStroke.Transparency = 0.2 buttonStroke.Parent = toggleButton local keybindTag = Instance.new("TextButton") keybindTag.Size = UDim2.new(0, 70, 0, 24) keybindTag.Position = UDim2.new(0, 14, 1, -43) keybindTag.BackgroundColor3 = Color3.fromRGB(20, 24, 42) keybindTag.BorderSizePixel = 0 keybindTag.Text = "Key: X" keybindTag.TextColor3 = Color3.fromRGB(210, 220, 255) keybindTag.Font = Enum.Font.GothamMedium keybindTag.TextSize = 13 keybindTag.AutoButtonColor = false keybindTag.ZIndex = 3 keybindTag.Parent = main local keyCorner = Instance.new("UICorner") keyCorner.CornerRadius = UDim.new(0, 8) keyCorner.Parent = keybindTag local keyStroke = Instance.new("UIStroke") keyStroke.Color = Color3.fromRGB(70, 90, 150) keyStroke.Thickness = 1 keyStroke.Transparency = 0.35 keyStroke.Parent = keybindTag local function updateUI() if systemEnabled then status.Text = "Status: Enabled" status.TextColor3 = Color3.fromRGB(90, 255, 140) toggleButton.Text = "ON" TweenService:Create(toggleButton, TweenInfo.new(0.15), { BackgroundColor3 = Color3.fromRGB(65, 115, 255) }):Play() else status.Text = "Status: Disabled" status.TextColor3 = Color3.fromRGB(255, 110, 110) toggleButton.Text = "OFF" TweenService:Create(toggleButton, TweenInfo.new(0.15), { BackgroundColor3 = Color3.fromRGB(80, 85, 100) }):Play() end if waitingForKeybind then keybindTag.Text = "..." else keybindTag.Text = "Key: " .. keybind.Name end if lockedTarget and lockedTarget.Character and lockedTarget.Character:FindFirstChild("Head") then targetLabel.Text = "Target: " .. lockedTarget.Name else targetLabel.Text = "Target: None" end end toggleButton.MouseButton1Click:Connect(function() systemEnabled = not systemEnabled if not systemEnabled then lockEnabled = false lockedTarget = nil end updateUI() end) toggleButton.MouseEnter:Connect(function() TweenService:Create(toggleButton, TweenInfo.new(0.12), { Size = UDim2.new(0, 110, 0, 36) }):Play() end) toggleButton.MouseLeave:Connect(function() TweenService:Create(toggleButton, TweenInfo.new(0.12), { Size = UDim2.new(0, 105, 0, 34) }):Play() end) keybindTag.MouseButton1Click:Connect(function() waitingForKeybind = true lockEnabled = false lockedTarget = nil TweenService:Create(keybindTag, TweenInfo.new(0.12), { BackgroundColor3 = Color3.fromRGB(35, 45, 75) }):Play() updateUI() end) -- Dragging local dragging = false local dragStart local startPos local dragInput topBar.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true dragStart = input.Position startPos = main.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end) end end) topBar.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then dragInput = input end end) UIS.InputChanged:Connect(function(input) if dragging and input == dragInput then local delta = input.Position - dragStart main.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end) UIS.InputBegan:Connect(function(input, gpe) if gpe then return end if waitingForKeybind then if input.UserInputType == Enum.UserInputType.Keyboard then keybind = input.KeyCode waitingForKeybind = false TweenService:Create(keybindTag, TweenInfo.new(0.12), { BackgroundColor3 = Color3.fromRGB(20, 24, 42) }):Play() updateUI() end return end if not systemEnabled then return end if input.KeyCode == keybind then if lockEnabled then lockEnabled = false lockedTarget = nil else lockedTarget = closestTarget() lockEnabled = lockedTarget ~= nil end updateUI() end end) RunService.RenderStepped:Connect(function() if not systemEnabled then return end if not lockEnabled or not lockedTarget then return end if not validTarget(lockedTarget) then lockEnabled = false lockedTarget = nil updateUI() return end local head = lockedTarget.Character and lockedTarget.Character:FindFirstChild("Head") if not head then lockEnabled = false lockedTarget = nil updateUI() return end local camPos = camera.CFrame.Position local targetCF = CFrame.lookAt(camPos, head.Position) camera.CFrame = camera.CFrame:Lerp(targetCF, 0.18) targetLabel.Text = "Target: " .. lockedTarget.Name end) updateUI()