Remove Right Click Turning

So when you hold right click and drag it around it rotates around your player. I don’t want this to be possible so how could I remove it?

  1. How could I do this by scripting?
  2. Where should I put the script?
  3. Local or Normal?
1 Like

You can esaliy do this by changing CurrentCamera type to Scriptable, here is an example in localscript:

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable 

I hope this helps. :herb:

4 Likes

I put the local script w/ the code into the workspace but when I entered the game I could still rotate around my player

My bad I tottaly forgot we had localscript. Basically create local script and add it in StarterGui:

game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
1 Like

Alright I did that but now my camera is stuck in position unable to follow my player.

Trusting what @ArticGamerTV has said (seeing as I’m not really experienced with this type of camera manipulation), you would want to swap around the two equations, so the new code would look like this:

game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
1 Like

That just puts everything back to normal

I’m not sure whether or not there’s a way to do this without forking the Camera Scripts (and keeping the actual features of roblox’s camera system, e.g scrolling, first person, etc).

If you want to fork the camera scripts (you will not receive any camera script updates in the future, if roblox releases any) you’ll want to edit the functions responsible for enabling the panning mode.

Commenting (or removing) the code in these functions should disable right mouse movement. Do not remove the functions themselves otherwise the camera will try to call them and throw an error.
This does not stop the cursor from being locked in place while right clicking, not sure how to disable that.

1 Like

When you say remove the code do you just mean delete everything except the functions

Yes, or optionally comment the code out so that it will not run.

Here is my idea use RenderStepped instead (this is still a localscript), I will give you an example on how to use it but you will have to experiment with the valuses to get correct position of the camera, here you go:

game:GetService("RunService").RenderStepped:Connect(function()
    local Camera = workspace.CurrentCamera
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = CFrame.new((game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(-1, -1, -1)).Position, game.Players.LocalPlayer.Character.Head.Position) * CFrame.fromEulerAnglesXYZ(-1,-1,-1)  
end)

I hope this helps. :herb:

2 Likes

One more problem, my camera shakes up and down every foot step, It’s not the worst thing but is there a way to fix that?

This is somewhat of a hack, but if all else fails you can always use an ImageButton.
Set the Size set to {1, 0},{1, 0}
Set the Image to be blank
Set the BackgroundTransparency to 1

You get your desired effect of disabling right click to rotate camera.
disable camera drag.rbxm (2.4 KB)

3 Likes

Ok I downloaded and imported the file to starterGui but still nothing

Do you have that pervious LocalScript running?
Try disabling it

That ImageButton should take up the entire screen and prevent players from using right click to drag the camera around.

1 Like

I don’t think that might be possible at this point since we shouldn’t anchor the head of the player because we won’t be able to move or even spawn. This is doing because we attached a camera to head and we are playing animation on the character. This may maybe work if you delete the animation of the character. I hope this helps. :herb:

Edit: yeah try to delete the animation from the character.

1 Like

Thanks for all the help! Honestly the bounce is so small it’s hard to even notice.

1 Like

If you’re trying to remove the bounce using @ArticGamerTV’s code, try replacing

game.Players.LocalPlayer.Character.Head.Position

with

game.Players.LocalPlayer.Character.HumanoidRootPart.Position+Vector3.new(0,3,0)
1 Like

@ArticGamerTV (cc @TheYelloMacaroni) This is an ugly hack, stop using it. You’re going to encounter weird artifacts and this isn’t the proper way to do it anyway. If you want to remove right click turning, just prevent the right mouse button from passing input.

local ContextActionService = game:GetService("ContextActionService")

ContextActionService:BindActionAtPriority("NoRMBDrag", function()
    return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value, Enum.UserInputType.MouseButton2)

Consequently, in order to make any right mouse functions work, you must use the same method of ContextActionService bindings but use a higher priority value so it won’t be sunk by the above (Enum.ContextActionPriority.High.Value + NUM). IIRC Guis won’t be affected.

22 Likes

Dude thank you so much. Actually Worked

1 Like