Hello,
I wanted my game to have shiftlock always enabled no matter the circumstances. So I read a quick article and made a quick script to make it work.
-- // Variables
-- # Services
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local playersService = game:GetService("Players")
-- # Objects
local player = playersService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character.HumanoidRootPart
local humanoid = character.Humanoid
local camera = game.Workspace.CurrentCamera
-- // Functions
humanoid.CameraOffset = Vector3.new(1.75, 0, 0)
humanoid.AutoRotate = false
runService:BindToRenderStep("Shiftlock", Enum.RenderPriority.Character.Value, function()
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative
local _, y = camera.CFrame:ToEulerAnglesXYZ()
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * CFrame.Angles(0, y, 0)
end)
After testing the game I realized that my character would begin to inverse the rotation after rotating about 180 degress. I still haven’t found a solution yet and can’t explain the cause for it.
If anyone knows how to fix this issue I would gladly appreciate if you would help me!
Have a wonderful day.