Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to lock player in shift lock?

Asked by 4 years ago

I'm developing a game where there are tools which are equippable by scrolling the mouse wheel, however the mouse wheel is already bound to zooming in and out. Any way I could lock the player in the shift lock state? If not, maybe just point me in the right direction.

I have tried locking the Camera Min/Max Zoom Distance property but that doesn't lock the cursor in place.

I have tried looking through all the properties of the player to try and find something helpful.

I have tried some of the Enum.CameraType's on the player.

I can't seem to find anything that works.

0
Camera manipulations is always a mess. I'm stuck on same thing rn. Hope this bumps the question ItsNimbusCloud 66 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Ok, I lurked around for a while and came up with a kinda hacky solution:

First, go to StarterPlayer folder in Explorer and disable "EnableMouseLockOption"

Then create a local script in StarterPlayerScripts and put this in:

local Player = game.Players.LocalPlayer
repeat wait() until Player:HasAppearanceLoaded()


local cam = require(Player.PlayerScripts.PlayerModule.CameraModule).activeCameraController
local camLock = require(Player.PlayerScripts.PlayerModule.CameraModule.MouseLockController)

local offset = camLock:GetMouseLockOffset()

cam:SetIsMouseLocked(true)
cam:SetMouseLockOffset(offset)

It should techincally lock your player in shift-lock state and mouse zooming won't break it.

Lemme know if it works

0
Thanks! Really helped. User#25069 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I'm not too sure how to do that exactly, I'm sure there are different methods to doing that but something that can give similar functionality to what you want could be the "Enum.MouseBehavior.LockCenter" and I think it might be worth a look.

More info here

0
Tried it but doesn't seem to be doing anything. Thanks though. User#25069 0 — 4y

Answer this question