Advertisement
Fyzeq

Mobile Shift Lock!

Dec 24th, 2020
16,591
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 1 0
  1. --Scripted by FilipFree_Stylee
  2.  
  3. local SHOW_CENTER_CURSOR = true
  4.  
  5. local MOBILE_ENABLED = true
  6. local CONSOLE_ENABLED = true
  7.  
  8. local CONSOLE_BUTTON = Enum.KeyCode.ButtonR2
  9.  
  10. local UserInputService = game:GetService("UserInputService")
  11. local RunService = game:GetService("RunService")
  12. local GuiService = game:GetService("GuiService")
  13.  
  14. local Player = game.Players.LocalPlayer
  15.  
  16. local IsMobile = UserInputService.TouchEnabled
  17. local IsConsole = GuiService:IsTenFootInterface()
  18.  
  19. local UserGameSettings = UserSettings():GetService("UserGameSettings")
  20.  
  21. local offset = CFrame.new(1.75, 0, 0)
  22.  
  23. if (IsMobile and MOBILE_ENABLED) or (IsConsole and CONSOLE_ENABLED) then
  24. local Activated = false
  25.  
  26. local SHIFT_LOCK_OFF = 'rbxasset://textures/ui/mouseLock_off.png'
  27. local SHIFT_LOCK_ON = 'rbxasset://textures/ui/mouseLock_on.png'
  28. local SHIFT_LOCK_CURSOR = 'rbxasset://textures/MouseLockedCursor.png'
  29.  
  30. local middleFrame = Instance.new('Frame')
  31. middleFrame.Name = "MiddleIcon"
  32. middleFrame.Size = UDim2.new(.075, 0, .075, 0)
  33. middleFrame.Position = UDim2.new(.5, 0, .5, 0)
  34. middleFrame.AnchorPoint = Vector2.new(.5,.5)
  35. middleFrame.BackgroundTransparency = 1
  36. middleFrame.ZIndex = 10
  37. middleFrame.Visible = true
  38. middleFrame.Parent = script.Parent
  39.  
  40. local MouseLockCursor = Instance.new('ImageLabel')
  41. MouseLockCursor.Name = "MouseLockLabel"
  42. MouseLockCursor.Size = UDim2.new(1, 0, 1, 0)
  43. MouseLockCursor.Position = UDim2.new(0, 0, 0, 0)
  44. MouseLockCursor.BackgroundTransparency = 1
  45. MouseLockCursor.Image = SHIFT_LOCK_CURSOR
  46. MouseLockCursor.Visible = false
  47. MouseLockCursor.Parent = middleFrame
  48.  
  49. local arc = Instance.new("UIAspectRatioConstraint")
  50. arc.AspectRatio = 1
  51. arc.DominantAxis = "Height"
  52. arc.Parent = middleFrame
  53.  
  54. if IsMobile and MOBILE_ENABLED then
  55.  
  56. local frame = Instance.new('Frame')
  57. frame.Name = "BottomLeftControl"
  58. frame.Size = UDim2.new(.1, 0, .1, 0)
  59. frame.Position = UDim2.new(1, 0, 1, 0)
  60. frame.AnchorPoint = Vector2.new(1,1)
  61. frame.BackgroundTransparency = 1
  62. frame.ZIndex = 10
  63. frame.Parent = script.Parent
  64.  
  65. local ShiftLockIcon = Instance.new('ImageButton')
  66. ShiftLockIcon.Name = "MouseLockLabel"
  67. ShiftLockIcon.Size = UDim2.new(1, 0, 1, 0)
  68. ShiftLockIcon.Position = UDim2.new(-2.775, 0, -1.975, 0)
  69. ShiftLockIcon.BackgroundTransparency = 1
  70. ShiftLockIcon.Image = SHIFT_LOCK_OFF
  71. ShiftLockIcon.Visible = true
  72. ShiftLockIcon.Parent = frame
  73.  
  74. local arc2 = Instance.new("UIAspectRatioConstraint")
  75. arc2.AspectRatio = 1
  76. arc2.DominantAxis = "Height"
  77. arc2.Parent = frame
  78.  
  79. ShiftLockIcon.Activated:connect(function()
  80. Activated = not Activated
  81.  
  82. ShiftLockIcon.Image = Activated and SHIFT_LOCK_ON or SHIFT_LOCK_OFF
  83. MouseLockCursor.Visible = Activated and SHOW_CENTER_CURSOR
  84. end)
  85. end
  86.  
  87. if IsConsole and CONSOLE_ENABLED then
  88. UserInputService.InputBegan:Connect(function(input)
  89. if input.KeyCode == CONSOLE_BUTTON then
  90. Activated = not Activated
  91.  
  92. MouseLockCursor.Visible = Activated and SHOW_CENTER_CURSOR
  93. end
  94. end)
  95. end
  96.  
  97. local function OnStep()
  98. if Activated then
  99. UserGameSettings.RotationType = Enum.RotationType.CameraRelative
  100.  
  101. local Camera = workspace.CurrentCamera
  102. if Camera then
  103.  
  104. if (Camera.Focus.Position - Camera.CFrame.Position).Magnitude >= 0.99 then
  105. Camera.CFrame = Camera.CFrame * offset
  106. Camera.Focus = CFrame.fromMatrix(Camera.Focus.Position, Camera.CFrame.RightVector, Camera.CFrame.UpVector) * offset
  107. end
  108. end
  109. end
  110. end
  111. RunService:BindToRenderStep("Mobile/ConsoleShiftLock",Enum.RenderPriority.Camera.Value+1,OnStep)
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement