Disable M2 mouse lock?

Hello! My game has a 2.5D camera, and holding right mouse button locks the mouse while you move it, but the camera is stationary. I need the mouse to not lock while right mouse is held.

1 Like

I mean, I don’t think there is a good way to do it, or at least a method that I know of, but you can try to set the mouses behaviour to default each frame, though it is definitely not the best solution.

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	UserInputService.MouseBehavior = Enum.MouseBehavior.Default
end)
1 Like

You could use The Context Action Service Property
“Sink” to disable any functions connected to the righ mb

local ContextActionService = game:GetService(“ContextActionService”)

ContextActionService:BindActionAtPriority(“RightMouseDisable”, function()
return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.Medium.Value, Enum.UserInputType.MouseButton2)

1 Like

this worked, but now M2 does absolutely nothing, even though i have InputBegan connected to it

Hmmm.

Well since the script uses sink that disconnects all functions and input from mb2 you could try editing the roblox camera through starter player properties or you could script a camera that always looks and follows the characters humanoid so if yuo do that you would use aomething like (local script)

local camera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character

repeat
task.wait()
camera.CameraType = Enum.CameraType.Scriptable

until camera.CameraType = Enum.CameraType.Scriptable

camera.CameraSubject = char.HumanoidRootPart

local function UpdateCamera()
camera.CFrame = Cframe.new()
end

While task.wait() do
UpdateCamera()
end

Note: in Cframe.new() put the coordinates of the rootpart and add how much space tou want to be between the rootpart and camera on that axis

also you could use the cframe.lookat code but im not expierinced in that yet so i dont exactly how to use it

3 Likes

You camera mode needs to be on the Scriptable Enum-type.

-- Make sure its scriptable
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

it is

Please send your script, because it may be an internal issue!

There’s already a solved topic toward this.

buddy, you speak like an AI, thats not the issue OP is trying to solve.

1 Like

Bro, this guy’s got me waiting and itching. I just searched something because I’m going to bed, this reply certainly sent me to it, Thank you. :mad:

that script is almost exactly the same as what i have

why’d you have to make this so hard to disable roblox :pray:

btw i believe there is a way to change the roblox camera module script and altar its properties im not sure how to tho but ive seen tutorials on how to

1 Like

i am still digging in the player modules trying to find a solution

i FINALLY fixed it with this slightly hacky line of code

UIS:GetPropertyChangedSignal("MouseBehavior"):Connect(function()
	UIS.MouseBehavior = Enum.MouseBehavior.Default
end)

(UIS = UserInputService, don’t judge my variable naming)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.