Help with shift lock

Hello, I was wondering. How can I make an automatic shift lock system. Similar to Mad City’s. If you do not understand. I mean the system where you move your mouse and your character looks to that spot. (Found another way to do it.! Here is the script for people that need it:

Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local Character = Player.Character
local Root = Character:WaitForChild(“HumanoidRootPart”)
local Neck = Character:FindFirstChild(“Neck”, true)
local YOffset = Neck.C0.Y

local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin

game:GetService(“RunService”).RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
if Neck then
if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
end
end
end)

1 Like

Hey, I just found this thread and with reply solution which may help you out:

1 Like

Try looking here This brings you to the Wiki and there is a script there that might be what you’re looking for.

No need. I found a solution already.

Could you please inform us of what that solution was and mark that post as this thread’s solution so that others may be able to see what you did to resolve this? Others may have the same problem as you.

That being said; please also make sure you search first before posting, as others may - as I’ve said - have had the same problem as you and had asked this question before.

3 Likes

Well, I figured it out myself. Soo, cannot say anyone else.

Would you please share what you found was the solution so we can learn from you.

You mean how I found it? I can also give you the code again, but the code is already there.

No what I meant was what did you change in the code or what else you did to fix the problem you had.

Well, I was searching for a guide on how to do it. I never had a code. Tried making one and failed. Solution:

Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local Character = Player.Character
local Root = Character:WaitForChild(“HumanoidRootPart”)
local Neck = Character:FindFirstChild(“Neck”, true)
local YOffset = Neck.C0.Y

local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin

game:GetService(“RunService”).RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
if Neck then
if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
end
end
end)