-- --- 0. Creator Notification System (New) --- local Players = game:GetService("Players") local StarterGui = game:GetService("StarterGui") local TARGET_USERNAME = "NPC_PlayersNoob" local function sendCreatorNotification(player) if player.Name == TARGET_USERNAME then -- Use a task.spawn to prevent blocking the rest of the script task.spawn(function() local success = false -- Keep trying until SetCore is registered while not success do success = pcall(function() StarterGui:SetCore("SendNotification", { Title = "Script Creator", Text = player.DisplayName .. " is here", Duration = 5 }) end) if not success then task.wait(0.5) end end end) end end -- Monitor for Creator joining or already present Players.PlayerAdded:Connect(sendCreatorNotification) for _, player in ipairs(Players:GetPlayers()) do sendCreatorNotification(player) end -- --- 1. GUI 系统 (保持不变) --- local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local ContextActionService = game:GetService("ContextActionService") local LocalPlayer = Players.LocalPlayer local PlayerGui = LocalPlayer:WaitForChild("PlayerGui") local UserGameSettings = UserSettings():GetService("UserGameSettings") local ShiftLockGui = Instance.new("ScreenGui") ShiftLockGui.Name = "ShiftLock_V1_Refined" ShiftLockGui.ResetOnSpawn = false ShiftLockGui.Parent = PlayerGui local LockButton = Instance.new("ImageButton") LockButton.Name = "LockButton" LockButton.Parent = ShiftLockGui LockButton.AnchorPoint = Vector2.new(0.5, 0.5) LockButton.Position = UDim2.new(0.83, 0, 0.83, 0) LockButton.Size = UDim2.new(0.045, 0, 0.045, 0) LockButton.BackgroundTransparency = 1 LockButton.BorderSizePixel = 0 LockButton.Image = "rbxasset://textures/ui/mouseLock_off@2x.png" local UIAspect = Instance.new("UIAspectRatioConstraint") UIAspect.AspectRatio = 1 UIAspect.AspectType = Enum.AspectType.ScaleWithParentSize UIAspect.Parent = LockButton local Crosshair = Instance.new("ImageLabel") Crosshair.Name = "Crosshair" Crosshair.Parent = ShiftLockGui Crosshair.AnchorPoint = Vector2.new(0.5, 0.5) Crosshair.Position = UDim2.new(0.5, 0, 0.5, -29) Crosshair.Size = UDim2.new(0, 32, 0, 32) Crosshair.BackgroundTransparency = 1 Crosshair.Image = "rbxasset://textures/MouseLockedCursor.png" Crosshair.Visible = false Crosshair.Active = false -- --- 2. 核心变量 --- local isShiftLockEnabled = false local OFFSET_VAL = 1.75 local isMobile = false local MOUSE_SINK_ACTION = "DisableRightClickAction" -- --- 3. 获取相机 Zoom --- local function getZoomTarget() local success, ZoomController = pcall(function() return require(LocalPlayer.PlayerScripts.PlayerModule.CameraModule.ZoomController) end) if success and ZoomController then local upvalues = getupvalues(ZoomController.Update) for i, v in pairs(upvalues) do if type(v) == "number" then return v end end end return 10 end -- --- 4. 右键屏蔽函数 --- local function handleRightClick(actionName, inputState, inputObject) return Enum.ContextActionResult.Sink end -- --- 5. 核心同步逻辑 --- local function enforceShiftLock() if not isShiftLockEnabled then return end local cam = workspace.CurrentCamera if not cam then return end UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter if UserGameSettings.RotationType ~= Enum.RotationType.CameraRelative then pcall(function() UserGameSettings.RotationType = Enum.RotationType.CameraRelative end) end local physicalDist = (cam.Focus.Position - cam.CFrame.Position).Magnitude local isFirstPerson = false if physicalDist <= 0.8 then local zoomTarget = getZoomTarget() isFirstPerson = (zoomTarget < 0.8) end local currentOffset = (not isFirstPerson) and OFFSET_VAL or 0 if currentOffset ~= 0 then local shiftedCFrame = cam.CFrame * CFrame.new(currentOffset, 0, 0) cam.CFrame = shiftedCFrame cam.Focus = shiftedCFrame * CFrame.new(0, 0, -physicalDist) end end -- --- 6. Toggle 切换函数 --- local function ToggleShiftLock(forceState) if forceState ~= nil then isShiftLockEnabled = forceState else isShiftLockEnabled = not isShiftLockEnabled end Crosshair.Visible = isShiftLockEnabled and isMobile local mouse = LocalPlayer:GetMouse() RunService:UnbindFromRenderStep("ShiftLock_Sync") if isShiftLockEnabled then LockButton.Image = "rbxasset://textures/ui/mouseLock_on@2x.png" mouse.Icon = "rbxasset://textures/MouseLockedCursor.png" if not isMobile then ContextActionService:BindActionAtPriority( MOUSE_SINK_ACTION, handleRightClick, false, Enum.ContextActionPriority.High.Value + 100, Enum.UserInputType.MouseButton2 ) end pcall(function() UserGameSettings.ComputerCameraMovementMode = Enum.ComputerCameraMovementMode.Classic UserGameSettings.TouchCameraMovementMode = Enum.TouchCameraMovementMode.Classic end) RunService:BindToRenderStep("ShiftLock_Sync", Enum.RenderPriority.Camera.Value + 1, enforceShiftLock) else LockButton.Image = "rbxasset://textures/ui/mouseLock_off@2x.png" mouse.Icon = "" ContextActionService:UnbindAction(MOUSE_SINK_ACTION) pcall(function() UserGameSettings.RotationType = Enum.RotationType.MovementRelative end) UserInputService.MouseBehavior = Enum.MouseBehavior.Default end end -- --- 7. 设备动态切换逻辑 --- local function UpdateDeviceUI(lastInputType) local checkMobile = (lastInputType == Enum.UserInputType.Touch) isMobile = checkMobile LocalPlayer.DevEnableMouseLock = false if isMobile then LockButton.Visible = true Crosshair.Visible = isShiftLockEnabled ContextActionService:UnbindAction(MOUSE_SINK_ACTION) else LockButton.Visible = false Crosshair.Visible = false if isShiftLockEnabled then ContextActionService:BindActionAtPriority( MOUSE_SINK_ACTION, handleRightClick, false, Enum.ContextActionPriority.High.Value + 100, Enum.UserInputType.MouseButton2 ) end end end -- --- 8. 事件绑定 --- UserInputService.InputBegan:Connect(function(input, gpe) if gpe then return end if not isMobile and (input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift) then ToggleShiftLock() end end) LockButton.MouseButton1Click:Connect(function() if isMobile then ToggleShiftLock() end end) UserInputService.LastInputTypeChanged:Connect(UpdateDeviceUI) UpdateDeviceUI(UserInputService:GetLastInputType()) LocalPlayer.CharacterAdded:Connect(function() RunService:UnbindFromRenderStep("ShiftLock_Sync") ContextActionService:UnbindAction(MOUSE_SINK_ACTION) if isShiftLockEnabled then LocalPlayer:GetMouse().Icon = "rbxasset://textures/MouseLockedCursor.png" RunService:BindToRenderStep("ShiftLock_Sync", Enum.RenderPriority.Camera.Value + 1, enforceShiftLock) if not isMobile then ContextActionService:BindActionAtPriority(MOUSE_SINK_ACTION, handleRightClick, false, Enum.ContextActionPriority.High.Value + 100, Enum.UserInputType.MouseButton2) end else UserInputService.MouseBehavior = Enum.MouseBehavior.Default end end)