Advertisement
C-H-4-0-S

Smooth Shiftlock

May 14th, 2024
43
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 1 0
  1. local UserInputService = game:GetService("UserInputService")
  2.  
  3. local shiftLocked = false
  4. local lerpSpeed = 0.1
  5.  
  6. UserInputService.InputBegan:Connect(function(input)
  7. if input.KeyCode == Enum.KeyCode.Q then
  8. shiftLocked = not shiftLocked
  9. end
  10. end)
  11.  
  12. game:GetService("RunService").RenderStepped:Connect(function()
  13. local player = game.Players.LocalPlayer
  14. local character = player.Character
  15. local humanoid = character and character:FindFirstChildOfClass("Humanoid")
  16.  
  17. if shiftLocked then
  18. local camera = workspace.CurrentCamera
  19. local cameraLookAt = camera.CFrame.lookVector
  20. local newLookAt = Vector3.new(cameraLookAt.x, 0, cameraLookAt.z).unit
  21.  
  22. -- Calculate the target orientation
  23. local targetOrientation = CFrame.new(character.PrimaryPart.Position, character.PrimaryPart.Position + newLookAt)
  24.  
  25. -- Use Lerping to gradually rotate the player towards the target orientation
  26. local lerpedOrientation = character.PrimaryPart.CFrame:Lerp(targetOrientation, lerpSpeed)
  27.  
  28. -- Set the player's orientation
  29. character:SetPrimaryPartCFrame(lerpedOrientation)
  30. end
  31.  
  32. -- Update the player's movement
  33. if humanoid and not shiftLocked then
  34. -- Insert your movement code here
  35. end
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement