I’ve seen other threads on this topic,but I’ve never been able to truly find I want.
I’m looking for the regular camera behaviour to be as if: Shiftlock was on,but the player did not rotate,or more simply as camera moving as if right click was constantly held.
I’ve seen uses of changing MouseBehaviour but I’m looking for a method to also allow regular shiftlock alongside this specific camera mode.
UserInputService.MouseBehavior is the only way to accomplish this. ShiftLock could also work too but you would need to set it to LockCenter every frame.
You can easily just call MouseBehavior = Enum.MouseBehavior.LockCurrentPosition every tick.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetPlayers = ReplicatedStorage:WaitForChild("GetPlayers")
local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera
while true do
local PlayerGui = Player:WaitForChild("PlayerGui")
local MouseBehavior = PlayerGui:WaitForChild("MouseBehavior")
local MouseLock = MouseBehavior:WaitForChild("MouseLock")
local MouseLockValue = MouseLock.Value
if MouseLockValue == true then
Camera.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
end
end
This will lock the camera in place as long as the property MouseLock is set to true.
Since roblox has the feature already it isn’t hard to enable it. It just took some time to find it.
Find the PlayerModule in PlayerScripts if you already have it there, then find the child “BaseCamera” or PlayerModule → CameraModule → BaseCamera.
Require the script in whatever script you’re using as a module script.
Jump to line 1070 also called the function “OnMousePanButtonPressed.”
Replace its code with this,
function BaseCamera:OnMousePanButtonPressed(input, processed, isEquipped)
self:UpdateMouseBehavior()
self.panBeginLook = self.panBeginLook or self:GetCameraLookVector()
if isEquipped ~= nil then
self.startPos = self.startPos or Vector3.new(input.X, input.Y, 0)
else
self.startPos = self.startPos or input.Position
end
self.lastPos = self.lastPos or self.startPos
self.userPanningTheCamera = true
end
Now go back to the script where you required the function and invoke it like so (Make sure it’s only called once)