1 | local ShiftLockScreenGui = Instance.new("ScreenGui") |
2 | local ShiftLockButton = Instance.new("ImageButton") |
3 | local ShiftlockCursor = Instance.new("ImageLabel") |
4 | local CoreGui = game:GetService("CoreGui") |
5 | local Players = game:GetService("Players") |
6 | local RunService = game:GetService("RunService") |
7 | local ContextActionService = game:GetService("ContextActionService") |
8 | local Player = Players.LocalPlayer |
9 | local UserInputService = game:GetService("UserInputService") |
10 | local States = { |
11 | |
12 | |
13 | Lock = "rbxasset://textures/MouseLockedCursor.png", |
14 | Lock2 = "rbxasset://SystemCursors/Cross" |
15 | } |
16 | local MaxLength = 900000 |
17 | local EnabledOffset = CFrame.new(1.7, 0, 0) |
18 | local DisabledOffset = CFrame.new(-1.7, 0, 0) |
19 | local Active |
20 | |
21 | ShiftLockScreenGui.Name = "Shiftlock (CoreGui)" |
22 | ShiftLockScreenGui.Parent = CoreGui |
23 | ShiftLockScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling |
24 | ShiftLockScreenGui.ResetOnSpawn = false |
25 | |
26 | ShiftLockButton.Parent = ShiftLockScreenGui |
27 | ShiftLockButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255) |
28 | ShiftLockButton.BackgroundTransparency = 1.000 |
29 | ShiftLockButton.Position = UDim2.new(0.8, 0, 0.35, 0) |
30 | ShiftLockButton.Size = UDim2.new(0.0636147112, 0, 0.0661305636, 0) |
31 | ShiftLockButton.SizeConstraint = Enum.SizeConstraint.RelativeXX |
32 | ShiftLockButton.Image = States.Off |
33 | |
34 | ShiftlockCursor.Name = "Shiftlock Cursor" |
35 | ShiftlockCursor.Parent = ShiftLockScreenGui |
36 | ShiftlockCursor.Image = States.Lock |
37 | ShiftlockCursor.Size = UDim2.new(0.03, 0, 0.03, 0) |
38 | ShiftlockCursor.Position = UDim2.new(0.5, 0, 0.5, 0) |
39 | ShiftlockCursor.AnchorPoint = Vector2.new(0.5, 0.5) |
40 | ShiftlockCursor.SizeConstraint = Enum.SizeConstraint.RelativeXX |
41 | ShiftlockCursor.BackgroundTransparency = 1 |
42 | ShiftlockCursor.BackgroundColor3 = Color3.fromRGB(255, 0, 0) |
43 | ShiftlockCursor.Visible = false |
44 | |
45 | ShiftLockButton.MouseButton1Click:Connect( |
46 | function() |
47 | if not Active then |
48 | Active = |
49 | RunService.RenderStepped:Connect( |
50 | function() |
51 | Player.Character.Humanoid.AutoRotate = false |
52 | ShiftLockButton.Image = States.On |
53 | ShiftlockCursor.Visible = true |
54 | Player.Character.HumanoidRootPart.CFrame = |
55 | CFrame.new( |
56 | Player.Character.HumanoidRootPart.Position, |
57 | Vector3.new( |
58 | workspace.CurrentCamera.CFrame.LookVector.X * MaxLength, |
59 | Player.Character.HumanoidRootPart.Position.Y, |
60 | workspace.CurrentCamera.CFrame.LookVector.Z * MaxLength |
61 | ) |
62 | ) |
63 | workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * EnabledOffset |
64 | workspace.CurrentCamera.Focus = |
65 | CFrame.fromMatrix( |
66 | workspace.CurrentCamera.Focus.Position, |
67 | workspace.CurrentCamera.CFrame.RightVector, |
68 | workspace.CurrentCamera.CFrame.UpVector |
69 | ) * EnabledOffset |
70 | end |
71 | ) |
72 | else |
73 | Player.Character.Humanoid.AutoRotate = true |
74 | ShiftLockButton.Image = States.Off |
75 | workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * DisabledOffset |
76 | ShiftlockCursor.Visible = false |
77 | pcall( |
78 | function() |
79 | Active:Disconnect() |
80 | Active = nil |
81 | end |
82 | ) |
83 | end |
84 | end |
85 | ) |
86 | |
87 | local ShiftLockAction = ContextActionService:BindAction("Shift Lock", ShiftLock, false, "On") |
88 | ContextActionService:SetPosition("Shift Lock", UDim2.new(0.8, 0, 0.8, 0)) |
89 | |
90 | return {} and ShiftLockAction |