ScriptHUB
Centered Shift Lock Universal
40 Views
6d atrás
Descrição
Nenhuma descrição fornecida.
Como Utilizar?
Script
1local UserInputService = game:GetService("UserInputService")
2local RunService = game:GetService("RunService")
3local Players = game:GetService("Players")
4
5local player = Players.LocalPlayer
6local mouse = player:GetMouse()
7local camera = workspace.CurrentCamera
8local isLocked = false
9
10-- Settings
11local SHIFT_LOCK_ICON = "rbxasset://textures/MouseLockedCursor.png"
12local DEFAULT_ICON = ""
13local TOGGLE_KEY = Enum.KeyCode.CapsLock -- Keybind set to Caps Lock
14
15local function toggleShiftLock()
16 isLocked = not isLocked
17
18 if isLocked then
19 -- ENABLE: Shows lock icon and forces the mouse to the exact center
20 mouse.Icon = SHIFT_LOCK_ICON
21
22 RunService:BindToRenderStep("ForceCentralLock", Enum.RenderPriority.Last.Value, function()
23 local character = player.Character
24 if character and character:FindFirstChild("HumanoidRootPart") and character:FindFirstChild("Humanoid") then
25 -- Forces the mouse to the center of the screen
26 UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
27
28 -- Aligns the character with the camera (no side offset)
29 local _, y = camera.CFrame.Rotation:ToEulerAnglesYXZ()
30 character.HumanoidRootPart.CFrame =
31 CFrame.new(character.HumanoidRootPart.Position) * CFrame.Angles(0, y, 0)
32
33 -- Removes Roblox's default shoulder camera offset
34 character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
35 character.Humanoid.AutoRotate = false
36 end
37 end)
38 else
39 -- DISABLE: Releases the mouse and restores default behavior
40 RunService:UnbindFromRenderStep("ForceCentralLock")
41 UserInputService.MouseBehavior = Enum.MouseBehavior.Default
42 mouse.Icon = DEFAULT_ICON
43
44 local character = player.Character
45 if character and character:FindFirstChild("Humanoid") then
46 character.Humanoid.AutoRotate = true
47 character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
48 end
49 end
50end
51
52-- Detects when Caps Lock (or a side button mapped to Caps Lock) is pressed
53UserInputService.InputBegan:Connect(function(input, gameProcessed)
54 if gameProcessed then return end
55 if input.KeyCode == TOGGLE_KEY then
56 toggleShiftLock()
57 end
58end)Criador
Jogos Suportados
Script Universal
Funciona na maioria dos jogos.
Tags
universalshift lock
