Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- local shiftLocked = false
- local lerpSpeed = 0.1
- UserInputService.InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.Q then
- shiftLocked = not shiftLocked
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- local player = game.Players.LocalPlayer
- local character = player.Character
- local humanoid = character and character:FindFirstChildOfClass("Humanoid")
- if shiftLocked then
- local camera = workspace.CurrentCamera
- local cameraLookAt = camera.CFrame.lookVector
- local newLookAt = Vector3.new(cameraLookAt.x, 0, cameraLookAt.z).unit
- -- Calculate the target orientation
- local targetOrientation = CFrame.new(character.PrimaryPart.Position, character.PrimaryPart.Position + newLookAt)
- -- Use Lerping to gradually rotate the player towards the target orientation
- local lerpedOrientation = character.PrimaryPart.CFrame:Lerp(targetOrientation, lerpSpeed)
- -- Set the player's orientation
- character:SetPrimaryPartCFrame(lerpedOrientation)
- end
- -- Update the player's movement
- if humanoid and not shiftLocked then
- -- Insert your movement code here
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement