Mr_3242

Shiftlock

Jun 3rd, 2026
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | Gaming | 0 0
  1. local p = game:GetService("Players")
  2. local rs = game:GetService("RunService")
  3. local uis = game:GetService("UserInputService")
  4. local ts = game:GetService("TweenService")
  5. local lp = p.LocalPlayer
  6. local mouse = lp:GetMouse()
  7. local cam = workspace.CurrentCamera
  8. local active = false
  9. local conn = nil
  10. local char = lp.Character or lp.CharacterAdded:Wait()
  11. local hum = char:WaitForChild("Humanoid")
  12. local hrp = char:WaitForChild("HumanoidRootPart")
  13. local off_val = Vector3.new(2.2, 0.7, 0)
  14. local transition_info = TweenInfo.new(0.35, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
  15.  
  16. local g = Instance.new("ScreenGui")
  17. g.Name = "UniversalSystem"
  18. g.ResetOnSpawn = false
  19. g.IgnoreGuiInset = true
  20. g.Parent = lp:WaitForChild("PlayerGui")
  21.  
  22. local b = Instance.new("ImageButton")
  23. b.Name = "ShiftLockButton"
  24. b.Size = UDim2.new(0, 55, 0, 55)
  25. b.Position = UDim2.new(0.9, -35, 0.5, -27)
  26. b.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  27. b.BackgroundTransparency = 0.4
  28. b.Image = "rbxasset://textures/ui/[email protected]"
  29. b.Visible = uis.TouchEnabled
  30. b.ZIndex = 10
  31. b.Parent = g
  32.  
  33. local corner = Instance.new("UICorner")
  34. corner.CornerRadius = UDim.new(1, 0)
  35. corner.Parent = b
  36.  
  37. local stroke = Instance.new("UIStroke")
  38. stroke.Thickness = 2.5
  39. stroke.Color = Color3.fromRGB(255, 255, 255)
  40. stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
  41. stroke.Parent = b
  42.  
  43. local cur = Instance.new("ImageLabel")
  44. cur.Name = "CustomCursor"
  45. cur.Size = UDim2.new(0, 28, 0, 28)
  46. cur.Position = UDim2.new(0.5, 0, 0.5, 0)
  47. cur.AnchorPoint = Vector2.new(0.5, 0.5)
  48. cur.BackgroundTransparency = 1
  49. cur.Image = "rbxasset://textures/MouseLockedCursor.png"
  50. cur.ImageColor3 = Color3.fromRGB(255, 255, 255)
  51. cur.Visible = false
  52. cur.ZIndex = 5
  53. cur.Parent = g
  54.  
  55. local function sync(state)
  56.     active = state
  57.     char = lp.Character
  58.     if char then
  59.         hum = char:FindFirstChildOfClass("Humanoid")
  60.         hrp = char:FindFirstChild("HumanoidRootPart")
  61.     end
  62.  
  63.     if active then
  64.         b.Image = "rbxasset://textures/ui/[email protected]"
  65.         b.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  66.         b.ImageColor3 = Color3.fromRGB(0, 0, 0)
  67.         cur.Visible = true
  68.         if hum then hum.AutoRotate = false end
  69.        
  70.         if conn then conn:Disconnect() end
  71.         conn = rs.RenderStepped:Connect(function()
  72.             if active and char and hrp and hum and hum.Health > 0 then
  73.                 local cam_cf = cam.CFrame
  74.                 local _, y, _ = cam_cf:ToEulerAnglesYXZ()
  75.                 hrp.CFrame = hrp.CFrame:Lerp(CFrame.new(hrp.Position) * CFrame.Angles(0, y, 0), 0.4)
  76.                 cam.SocketOffset = cam.SocketOffset:Lerp(off_val, 0.15)
  77.                 uis.MouseBehavior = Enum.MouseBehavior.LockCenter
  78.             else
  79.                 uis.MouseBehavior = Enum.MouseBehavior.Default
  80.             end
  81.         end)
  82.     else
  83.         b.Image = "rbxasset://textures/ui/[email protected]"
  84.         b.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  85.         b.ImageColor3 = Color3.fromRGB(255, 255, 255)
  86.         cur.Visible = false
  87.         if conn then conn:Disconnect() conn = nil end
  88.         if hum then hum.AutoRotate = true end
  89.         ts:Create(cam, transition_info, {SocketOffset = Vector3.new(0, 0, 0)}):Play()
  90.         uis.MouseBehavior = Enum.MouseBehavior.Default
  91.     end
  92. end
  93.  
  94. b.MouseButton1Click:Connect(function()
  95.     sync(not active)
  96. end)
  97.  
  98. uis.InputBegan:Connect(function(input, processed)
  99.     if not processed then
  100.         if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
  101.             sync(not active)
  102.         end
  103.     end
  104. end)
  105.  
  106. lp.CharacterAdded:Connect(function(nc)
  107.     char = nc
  108.     hum = nc:WaitForChild("Humanoid")
  109.     hrp = nc:WaitForChild("HumanoidRootPart")
  110.     task.wait(0.1)
  111.     if active then
  112.         hum.AutoRotate = false
  113.     end
  114. end)
  115.  
  116. rs.Heartbeat:Connect(function()
  117.     if active then
  118.         if hum and hum.Health <= 0 then
  119.             sync(false)
  120.         end
  121.     end
  122. end)
  123.  
  124. sync(true)
Tags: delta
Advertisement
Add Comment
Please, Sign In to add comment