How can I disable camera rotation with shift lock on while using a skill?

I would like that when using an ability the character remains static even with the shift lock activated, only that the character does not have the ability to rotate while using it

1 Like

Try to anchor the HumanoidRootPart, I made that on my game for beatdowns cutscenes and worked well.

upon anchoring the character, the character will not be able to move, however they can continue to rotate the camera, which would cause the player to rotate

1 Like

In order to achieve what you are looking for, you will have to write some extra code to accomplish this.
However, there is a lot of work that could be done to make this more efficient.
This is the code that I came up with the other day.
local UserInputService = game:GetService(“UserInputService”)

local function GetIsTouching()
local mouse = game.Players.LocalPlayer:GetMouse()
local part = workspace.CurrentCamera:ScreenPointToRay(mouse.X, mouse.Y, 0).Origin
local part2 = workspace.CurrentCamera:ScreenPointToRay(mouse.X, mouse.Y, 1).Origin
local ray = Ray.new(part, (part2 - part).unit * 1000)
local hit, pos = workspace:FindPartOnRayWithIgnoreList(ray, {game.Players.LocalPlayer.Character:GetChildren()})

local isTouching = false
if hit then
    isTouching = hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent:FindFirstChild("Humanoid")
end

return isTouching

end

local function GetShiftLock()
local mouse = game.Players.LocalPlayer:GetMouse()

if mouse:IsKeyDown(Enum.KeyCode.LeftShift) or mouse:IsKeyDown(Enum.KeyCode.RightShift) then
    return true
end
return false

end

local function UpdateCamera()
local shiftLock = GetShiftLock()
local isTouching = GetIsTouching()

if isTouching then
    workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed
end

if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCurrentPosition and shiftLock then
    if not isTouching then
        workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
        UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
    else
        UserInputService.MouseBehavior = Enum.MouseBehavior.Default
    end
elseif UserInputService.MouseBehavior ~= Enum.MouseBehavior.Default and not shiftLock then
    if not isTouching then
        UserInputService.MouseBehavior = Enum.MouseBehavior.Default
    end
end

end

UserInputService.InputBegan:Connect(function(input, gpe)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
UpdateCamera()
end
end)

UserInputService.InputEnded:Connect(function(input, gpe)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
UpdateCamera()
end
end)

What this code does is that it checks to see if the player is holding down the left or right shift key, and if they are, it checks to see if the player is touching an object with a humanoid (such as a character) in front of them. If the player is touching a humanoid, the camera will not change, and if the player is not touching a humanoid, then the camera will change.