I just want to test if this solution would work as i see this has already been solved. Try this
local UserInputService = game:GetService("UserInputService")
-- Shift keys
local shiftKeyL = Enum.KeyCode.LeftShift
local shiftKeyR = Enum.KeyCode.RightShift
-- Return whether left or right shift keys are down
local function IsShiftKeyDown()
return UserInputService:IsKeyDown(shiftKeyL) or UserInputService:IsKeyDown(shiftKeyR)
end
-- Handle user input began differently depending on whether a shift key is pressed
local function Input(input, gameProcessedEvent)
if not IsShiftKeyDown() then
-- Normal input
else
-- Shift input
end
end
UserInputService.InputBegan:Connect(Input)
--Now add either the ShiftKeyR or ShiftKeyL depending on which one you want locked and it should look something like this:
while 2+2 == 4 = true do
ShiftKeyL = true
end
It gets ENABLED - not forced, but I again, get the posibility to toggle the shift lock by pressing shift.
But not forced, it just lets me enable it.
Is there any way that I can force the shiftlock thing to “On” and it is not possible to change it?
Look at this video for a better understanding! https://vimeo.com/430316711
This happens when I have the enable mouse lock option set to false. If I have it set to true it works.
But the player needs to have the shiftlock option to “On” and not “Off”. So, if players have it set to “Off” they will bypass the whole thing and essentialy destroy the games experience…
What I mean is how do you do that? I can’t find the script in the workspace, and to my knowledge, you can’t edit a script mid-game using another script
Join The Game in studio and go into you player find a folder called player scripts and you will find a script called PlayerModule Copy that and exit the game session paste it in StarterPlayer → StarterPlayerScripts find Camera Module under that and then Go to line 468 where it says CameraModule:Update(dt) then type this line of code
I know this is from a really long time ago, but I have to say, I tried that method to add shiftlock aiming for guns and I was experiencing HUGE performance hindrances, and the hindrances got worse and worse the more time you spent in the game. This is because the :Update() function is called about once every 8 milliseconds or so, meaning, that if you set connections like I did (To make it detect when a weapon is equipped) It will make thousands of connections to the RBXScriptSignal. The fix was very simple. Outside of the function, I set a variable called “connected” to false, and had an if statement inside of the function saying if connected == false then [I put the stuff I wanna happen here] end, and I put connected = true inside of it. If anyone is going to use this method for connections, you must use this method, otherwise there will be a huge amount of lag.
I’ve never experience major performance hits using this, but it never stops helping to improve! I’ve noticed that in studio sometimes it lags more than actual gameplay so I’ve been using a mix of both to test my game, my fix was more of a quick workaround as well so I didn’t really plan for optimizations as I never personally experienced any.
Were you using [RBXScriptSignal]:Connect() Inside of the update function? Also, if you have a powerful gaming laptop/PC, and your tests aren’t too long, you won’t notice the lag, but players with lower-end devices going for longer playsessions will experience it alot.
I made this when I had a less powerful PC and I rarely ran into any lag issues atleast from my testing, I used to sit in some of my games to think about what I would program next, and no, you should NEVER use a connect in a loop.
As I said anything you can do to improve is good, just from my own testing when I used it i never had any major issues regarding the update function, as long as you didn’t put like something that eats power for breakfast, of course now my pc is a bit more up to date, I don’t run into those issues as much so it would be hard to test with more strenuous code on my part as my computer can do more calculations.