Скрытое содержимое
-- Поместите этот LocalScript в StarterPlayer -> StarterPlayerScripts
-- Назовите его "MouseManager"
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Переменные состояния
local isMouseLocked = true
local hintText = nil
local screenGui = nil
local cameraConnection = nil
local lastCameraCFrame = nil
-- === ФУНКЦИЯ БЛОКИРОВКИ МЫШИ (РЕЖИМ ИГРЫ) ===
local function lockMouse()
isMouseLocked = true
mouse.Icon = ""
UserInputService.MouseIconEnabled = false
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
-- Отключаем фиксацию камеры
if cameraConnection then
cameraConnection:Disconnect()
cameraConnection = nil
end
-- Обновляем текст
if hintText then
hintText.Text = "

Мышь заблокирована | Нажмите V для разблокировки"
end
print("

Мышь заблокирована (камера свободна)")
end
-- === ФУНКЦИЯ РАЗБЛОКИРОВКИ МЫШИ (РЕЖИМ МЕНЮ) ===
local function unlockMouse()
isMouseLocked = false
mouse.Icon = "rbxasset://SystemCursors/Arrow"
UserInputService.MouseIconEnabled = true
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
-- Сохраняем текущее положение камеры
if workspace.CurrentCamera then
lastCameraCFrame = workspace.CurrentCamera.CFrame
end
-- Отключаем старую фиксацию если есть
if cameraConnection then
cameraConnection:Disconnect()
end
-- Фиксируем камеру в последнем положении (только поворот и позицию)
cameraConnection = RunService.RenderStepped:Connect(function()
if not isMouseLocked and workspace.CurrentCamera and lastCameraCFrame then
-- ВАЖНО: фиксируем только CFrame камеры, не трогая мышь
workspace.CurrentCamera.CFrame = lastCameraCFrame
end
end)
-- Обновляем текст
if hintText then
hintText.Text = "

Мышь разблокирована | Нажмите V для блокировки"
end
print("

Мышь разблокирована (камера зафиксирована, курсор свободен)")
end
-- === ПЕРЕКЛЮЧЕНИЕ СОСТОЯНИЯ ===
local function toggleMouse()
if isMouseLocked then
unlockMouse()
else
lockMouse()
end
end
-- === СОЗДАНИЕ ТЕКСТА-ПОДСКАЗКИ ===
local function createHintText()
screenGui = Instance.new("ScreenGui")
screenGui.Name = "MouseHintGui"
screenGui.Parent = player:WaitForChild("PlayerGui")
screenGui.ResetOnSpawn = false
-- Фон для текста
local hintFrame = Instance.new("Frame")
hintFrame.Name = "HintFrame"
hintFrame.Parent = screenGui
hintFrame.Size = UDim2.new(0, 320, 0, 36)
hintFrame.Position = UDim2.new(1, -50, 1, -50)
hintFrame.AnchorPoint = Vector2.new(1, 1)
hintFrame.BackgroundTransparency = 0.5
hintFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
hintFrame.BorderSizePixel = 1
hintFrame.BorderColor3 = Color3.fromRGB(80, 80, 80)
local frameCorner = Instance.new("UICorner")
frameCorner.CornerRadius = UDim.new(0, 8)
frameCorner.Parent = hintFrame
local frameStroke = Instance.new("UIStroke")
frameStroke.Parent = hintFrame
frameStroke.Thickness = 2
frameStroke.Color = Color3.fromRGB(120, 120, 120)
frameStroke.Transparency = 0.2
-- Текст
hintText = Instance.new("TextLabel")
hintText.Name = "HintText"
hintText.Parent = hintFrame
hintText.Size = UDim2.new(1, -16, 1, -8)
hintText.Position = UDim2.new(0, 8, 0, 4)
hintText.BackgroundTransparency = 1
hintText.TextColor3 = Color3.fromRGB(220, 220, 220)
hintText.TextSize = 14
hintText.Font = Enum.Font.GothamMedium
hintText.Text = "

Мышь заблокирована | Нажмите V для разблокировки"
hintText.TextXAlignment = Enum.TextXAlignment.Center
hintText.TextYAlignment = Enum.TextYAlignment.Center
hintText.TextWrapped = true
print("

Подсказка создана")
end
-- === ОБРАБОТКА КЛАВИШ ===
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.V then
toggleMouse()
end
-- Esc всегда разблокирует мышь
if input.KeyCode == Enum.KeyCode.Escape then
if isMouseLocked then
unlockMouse()
end
end
end)
-- === КЛИК В ИГРОВОЙ МИР БЛОКИРУЕТ МЫШЬ ОБРАТНО ===
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not isMouseLocked and input.UserInputType == Enum.UserInputType.MouseButton1 and not gameProcessed then
lockMouse()
end
end)
-- === ВОЗВРАТ В ИГРУ — БЛОКИРУЕМ МЫШЬ ===
UserInputService.WindowFocused:Connect(function()
lockMouse()
end)
-- === ВОЗРОЖДЕНИЕ — БЛОКИРУЕМ МЫШЬ ===
player.CharacterAdded:Connect(function()
lockMouse()
end)
-- === ИНИЦИАЛИЗАЦИЯ ===
createHintText()
lockMouse()
print("

Скрипт мыши загружен!")
print("

V — разблокировать мышь (камера заморожена, курсор свободен)")
print("

ЛКМ в игровой мир — заблокировать мышь обратно")