Can’t you just enable “Modal” on the gui?
Modal only frees the mouse in conditions where it’d normally be locked (i.e. zoomed in with a Gui plastered on your screen). It doesn’t force third person nor does it coerce the mouse to stay in the center of the screen.
You could achieve this functionality through editing the PlayerModule so that it is always on shift-lock mode, as opposed to only when the player makes it be. Id start by looking in the “MouseLockController” module or maybe “BaseCamera”, both children of CameraModule.
You will need to use the old camera script. If you put it in, the new control script should still be active. You can find one in free models and edit it your self.
Why the old one? I did it with the new one just fine
Inside function CameraModule:Update(dt)
for the CameraModule, you can force shiftlock automatically on
by putting the following code into it
self.activeCameraController:SetIsMouseLocked(true)
If you want rotation you change you can also
GameSettings.RotationType = Enum.RotationType.CameraRelative
or
GameSettings.RotationType = Enum.RotationType.MovementRelative
Using this you can also set up certain conditions for when and if the camera will be forced in situations.
Also you can turn off the toggle players have for shift lock automatically if you go to StarterPlayer.EnableMouseLockOption.
EDIT: alternatively you can used this old forked script.
https://www.roblox.com/library/5173113621/Force-Shiftlock-Forked-Playermodule
This is nice. However, setting the activeCameraController to true does not immediately turn it on when the player joins. They still manually need to toggle shiftlock on and off for them to be stuck in it. I personally have tried settings the mouses X & Y to the middle of the screen when the mouse is moved but you cannot set these values only read from them. I do not know another method of doing this.
Weird, using this method it kept it locked for me unless I forgot something vital, but I shouldn’t have.
I have tried to use this, and it works for the most part. The only part that doesn’t is that it doesn’t do the third person thing. It just locks the mouse and turns the player with the camera, but doesn’t do the third person camera part. Any way I can add that?
So you want to force the camera into third person, but not have it follow the camera?
No I want it to be exactly like shiftlock, which has 3 components:
- It locks the mouse in center
- The character looks towards mouse
- The camera is in third person
Right now, only the first 2 are achieved. How would I do the 3rd one?
you could change maxcamerazoom and mincamerazoom in starterplayer properties
That doesn’t make it third person, it just makes the zoom different.
you can set them both to the same value so the player is locked in third person and can’t zoom in-out?
That locks player into third person, but if the mouse is in the center of the screen, the player will be in the center. I want an over the shoulder type camera.
Use a localscript to access the humanoid in the player character, then in “CameraOffset” set the value of X to 1 or 2, that will have it on the shoulder instead of centered, sorry I was on a trip for a day and couldn’t answer back.
Thanks, that fixed it for me! It works perfectly now!
Sorry for bumping this old thread. But I didn’t quite get your explanation.
Should I have a script like this inside a local script in StarterPlayerScripts:
plrModule = script.Parent:WaitForChild("PlayerModule")
CameraModule = require(plrModule.CameraModule)
function CameraModule:Update(dt)
self.activeCameraController:SetIsMouseLocked(true)
end
I dont get any errors. But it doesnt do anything either.
Unfortunately this method relied on how the older camera scripts worked, and I think they changed a few things, I made this a while back while I was using it for my own game, but I decided to fish out my old games camera script and slightly document controls, it really was only a few adjustments, but for your use you’ll have to adjust it a bit more to your games liking, you may not be able to go to your ESC menu in studio but it should work in actual gameplay. https://www.roblox.com/library/5173113621/Force-Shiftlock-Forked-Playermodule
(Install into StarterPlayerScripts)
It’s most likely possible to do this with newer player camera scripts, but I have not been experimenting as I haven’t needed to for a while, this can be a temp fix and solution for any forced camera games, feel free to modify and even expand on it if you want, anyone who wants it can have it… enjoy! (Let’s hope one day we get official support for this so we don’t have to fork default roblox scripts )