So I am trying to make a shift lock script I have no clue how to do it though
can anyone tell me what functions and objects to use for this?
So I am trying to make a shift lock script I have no clue how to do it though
can anyone tell me what functions and objects to use for this?
I am not sure what you mean by shift lock script. If you are simply trying to turn the ability to use it on or off via script, you can use the DevEnableMouseLock property of the Player class, but this does not automatically put the player into shift lock mode.
If you do want a script that automatically simulates what shift lock mode does, you could try to change the player's HumanoidRootPart's CFrame and make the camera focus on it. This is from an old project I've made, but something like this may work (Of course, this is just a framework, and other wanted components will need to be written by yourself):
userInputService = game:GetService("UserInputService")
contextActionService = game:GetService("ContextActionService")
runService = game:GetService("RunService")
player = game:GetService("Players").LocalPlayer
camera = game.Workspace.CurrentCamera
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Lock mouse to center
x, y = 0, 0;
function getMouse(name, state, inputObject)
x = x + (-inputObject.Delta.x/250)
y = y + (-inputObject.Delta.y/250)
if y > 0.9 then --Top camera angle limit
y = 0.9 --Change this as well
elseif y < -1.3 then --Bottom camera angle limit
y = -1.3 --Change this as well
end
end
contextActionService:BindActionToInputTypes("MouseMove",getMouse,false,Enum.UserInputType.MouseMovement)
function camUpdate(hrp)
hrp.CFrame = CFrame.new(hrp.Position) * CFrame.Angles(0,x,0);
end
runService.RenderStepped:connect(function()
local character = player.Character
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp then
camUpdate(hrp)
camera.Focus = hrp.CFrame * CFrame.new(3,1,0)
camera.CFrame = hrp.CFrame * CFrame.new(3,1,12)
end
end)
Hope this helped
thank you very much!
Please accept if it helped :)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
What do you mean "shift look"?