Hello Dear Devforum community, I lately encountered this bug with a cutscene that I am making. I have an animation which plays and I rigged a part to the character which serves as the camera. It works perfectly fine and looks great but once you start the cutscene with shiftlock on it goes crazy and spins the entire time (video). I have tried disabling DevAllowShiftLock (I dont remember the name of the property) inside of the player which did disable shiftlock but the same bug occured. What could I do to prevent this without disabling shiftlock in the entire game?
Try disabling shift lock before the animation starts and then reenabling it after it’s over (if the user had it on to begin with).
This post should help.
Thanks for referencing my post, but as far as I’m aware, there currently is not a way to force a player to turn off shift-lock if they have already enabled it.
The solutions provided in my post can only achieve the following:
Provides a way to completely disable the ability to turn on shift lock before the server starts.
Provides a way to toggle whether or not players are allowed to enter or exit shiftlock mode mid-game.
The note I included for option 2 clarifies what the second option entails if a player currently is in shiftlock mode at the time the player-specific property is updated by a script:
So for OP, the only way that Option #2 would currently work for your game would be if it’s turned off early enough as to ensure that players do not enter shift lock prior to the cutscene (but that might be impossible if players enter shift lock mode a loooooong time before reaching that).
Since exiting a player out of shiftlock mode is not possible / does not have an intuitive solution at the moment, the only other option I can think of would be to:
Create a clone of the player’s Character model upon starting the cutscene (Edit: Or have an existing NPC model ready and apply a HumanoidDescription to it based on the player’s actual Character model. Example:
local ProximityPrompt = script.Parent
local npcPlaceholder = -- Path to placeholder character model
ProximityPrompt.Triggered:Connect(function(player)
local realCharacter = player.Character or player.CharacterAdded:Wait()
local realHumanoid = realCharacter:WaitForChild("Humanoid")
if realCharacter and realHumanoid then
local humanoidDescription = realHumanoid:GetAppliedDescription()
local characterClone = npcPlaceholder:Clone()
local humanoidClone = characterClone:WaitForChild("Humanoid")
humanoidClone:ApplyDescription(humanoidDescription)
characterClone.Parent = workspace
-- Animate the cloned character and continue with the cutscene
end
end)
Hide the original Character model / make it invisible
And then animate the cloned Character model, instead, since the cloned version would not be affected by the player being in shift lock mode.
Thats actualy possible.
I’m assuming your game uses the default camera modules. --you should try this even if your game doesnt it might work
also this only works on client --actualy havent tested on the server but i know its not gonna work on the server
so your going to have to create a LocalScript It has to be Called "PlayerScriptsLoader"--even though it doesnt load player scripts
you have to put
_G.PlayerModule=require(script.Parent:WaitForChild("PlayerModule"))
--[[
_G is a shared table between all scripts of the same script context
for example if a script running on Player1's client does _G.A="A"
then if a different script of the same client does print(_G.A)
then it prints "A"
but if a script on the server or a different player's client tries to print it
it will print nil
also _G probably does work on the server but i havent tested if it does
and probably doesnt replicate changes from server to client (also havent tested)
]]
in the script --my explaination on what _G is doesnt have to be included
and then when you want to disable shiftlock and force it off you do
_G.PlayerModule:ToggleShiftLock(false,true,false)
and to enable it
_G.PlayerModule:ToggleShiftLock(true)
and to force it on
_G.PlayerModule:ToggleShiftLock(false,true,true)
or you could make your own shiftlock system but thats less intuitive
oh well this solution is quite intuitive!--[[atleast for me]] And also _G needs to be used more.
would be happy if you credited me as one of the people who helped you make the game! --i wonder what game your making
hope this works for you! --[[it took me a while to make this reply]] and hope you have a good day! :D
Thanks for the suggestion, but there doesn’t seem to be a function called ToggleShiftLock in the current default PlayerModule or any of the other default scripts within the PlayerScripts. The closest I found was:
PlayerModule → CameraModule → MouseLockController, which has functions like:
EnableMouseLock
DoMouseLockSwitch
OnMouseLockToggled
etc.
It seems as if the ShiftLockController you referenced has been replaced by this new MouseLockController since 2018, based on the comment included at the top of the module:
--[[
MouseLockController - Replacement for ShiftLockController, manages use of mouse-locked mode
2018 Camera Update - AllYourBlox
--]]
I read through it and then tried experimenting with calling the EnableMouseLock function from a LocalScript (*placed in StarterPlayerScripts) but it didn’t really work as expected and I don’t have a full understanding of the MouseLockControllerModuleScript quite yet:
-- Example that didn't quite work as I would have hoped
local PlayerModule = script.Parent:WaitForChild("PlayerModule")
local CameraModule = PlayerModule:WaitForChild("CameraModule")
local MouseLockController = CameraModule:WaitForChild("MouseLockController")
local requiredModule = require(MouseLockController)
workspace:WaitForChild("Part1").Touched:Connect(function()
requiredModule:EnableMouseLock(true)
end)
workspace:WaitForChild("Part2").Touched:Connect(function()
requiredModule:EnableMouseLock(false)
end)
There’s probably a really easy way to make that work that I’m completely missing, but either way, hopefully there will be something integrated into the API at a later point that’ll make it simple for everyone to enter / exit players out of shift lock mode without needing to reference the core scripts and mess around with it.
Nonetheless, thanks for highlighting a solution that seems like it would work for those who are still using old camera modules (I am not sure how many people are still using ones from pre-2018 but I know it will help someone!), and also for bringing my attention to the CameraModule since I really would not have thought to check those corescripts otherwise lol
P.S. I had no idea the emoji was still available It’s amazing
Well uh. I was kinda too lazy to hit play and copy the PlayerModule and then hit stop then paste it in StarterPlayer.StarterPlayerScripts so i searched PlayerModule in the ToolBox and inserted the first result into StarterPlayer.StarterPlayerScripts which was PlayerModule [Toggle shiftlock] - Creator Store (roblox.com) and i ignored the fact it said Toggle shiftlock. You could insert the free model into your game or add
function PlayerModule:ToggleShiftLock(enable, modifiedVar, modifier)
self.cameras:ToggleShiftLock(enable, modifiedVar, modifier)
end
Hello there!
Thanks to your reply, I also found out that disabling shift lock while the player has it already enabled doesn’t work and your goaround seems like a very good idea and I will probably use this method. But I will also test with the ToggleShiftLock() function that @monkeymario1000 mentioned
Hello, I tried using the module with the toggleshiftlock function and I get the same result as before, either I am doing something wrong or there is just no way that this issue can be fixed in a way that I know. Thanks for your help but I will probably stick to the idea of duplicating the players character and making a dummy out of it.
Edit: I will mark the idea of cloning character soon
cuz that will make the player unable to toggle shiftlock BUT IT DOESNT AUTOMATICALLY DISABLE IT
and renabling shiftlock is as simple as doing
_G.PlayerModule:ToggleShiftLock(true)
The first part of the _G.PlayerModule:ToggleShiftLock() fuction is whether or not you want to allow the player toggle shfitlock the second part is if you want to change the state of shift lock the third part is what state you want to change it to each part of the function is a boolean
Hope this works for you and crediting me as one of the people who helped you would make me happy! :D
function PlayerModule:ToggleShiftLock(enable, modifiedVar, modifier)
self.cameras:ToggleShiftLock(enable, modifiedVar, modifier)
end
into the PlayerModule
make you did either of those
edit: wait i wonder are you using a custom camera?
another edit: also i dont count modified PlayerModule as a custom camera in this case