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.
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)
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.
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.
Edit: yeah try to delete the animation from the character.
Thanks for all the help! Honestly the bounce is so small it’s hard to even notice.
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)
@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.
Dude thank you so much. Actually Worked
It worked but when I try to move backward it just starts spinning around my player and going crazy. The camera position and angle affects the way the player moves so i was wondering if there is a way around that
Cue: my suggestion, which was evidently skipped over. This is why I said you should use my solution. Now because you’re using the RenderStepped camera lock, you’re running into additional problems and needing extra code. It’s more work than it’s worth.
You can either keep trying to apply hacks and workarounds which may ruin the player experience or require more maintenance from your end, or you can just remove all the turning-based work you’ve done until now from this thread and just use my solution. Less lines, cleaner removal supported natively by the API and generally a better solution.
One of the best ways around this in my opinion
and as @colbert2677 mentioned is using the ContextActionService. it will ultimately help you in the long run, using and manipulating the camera will not as much(unless you intend to create a whole camera controller). Tl;dr there is no clearcut and keep in mind, stable way as of now to disable right click for rotating the camera ( I’m pretty sure) using the current Camera Controller. Of course you could fork the player scripts and manipulate the camera, but this comes with some what of a “consequence”. Firstly the forked scripts and methods that you make will not update, to adapt with the newer/future versions of the camera and base camera controllers where as native player scripts will. And they could be prone to breaking especially if you intend to extensively customize the camera. The context action service might change some time in the future, but I would say it is a lot more stable and reliable then “overwriting” the camera to stop right mouse click movement overall, as it can “disable” the input as an action which can be less expensive and more beneficial in some aspects. Just my thoughts and recomendations, either way good luck on your project!
Honestly even i’m getting a little confused on my own topic, here’s what I’m trying to achieve.
D and A just move you, don’t turn you, your mouse is what moves you around.
Well, the rotating thing with the character is easy to change, as there is a built in property for it. Humanoid.AutoRotate can be used to toggle whether the humanoid rotates when they move (left or right). I am not sure what you mean by the mouse just moves you around, are you saying you want MouseButton1 to move the camera instead of MouseButton2?
Code Example
local player = game.Players.LocalPlayer
local Humanoid = player.Character:WaitForChild("Humanoid")
Humanoid.AutoRotate = false
Sounds like your camera mode is set to “Follow” try classic instead.
Read the post they’re replying to for context. It doesn’t have to do with the camera mode; it has to do with the code that was posted. The code in question sets the Camera CFrame to a certain point through a listener on RenderStepped.
I mean that just moving your mouse, not pressing anything rotates you around.
Okay so I put
local player = game.Players.LocalPlayer
local Humanoid = player.Character:WaitForChild(“Humanoid”)
Humanoid.AutoRotate = false
in a LcalScript in StarterGui but i want it so that when you move your mouse across the screen without clicking any buttons you turn that direction.