Animation goes crazy when shiftlock enabled

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?

NORMAL:


WITH SHIFTLOCK:

4 Likes

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.

2 Likes

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:

  1. Provides a way to completely disable the ability to turn on shift lock before the server starts.
  2. 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).

Maybe it’ll be possible in the future to exit players out of shiftlock mode in the future with something like the MouseBehavior property, since it seemed that Roblox wanted developers to rely on that property to handle shiftlock behavior when they temporarily deprecated both EnableMouseLockOption and DevEnableMouseLock, but then those properties were brought back / undeprecated because there were unforseen issues.

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:

  1. 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)
  1. Hide the original Character model / make it invisible

  2. And then animate the cloned Character model, instead, since the cloned version would not be affected by the player being in shift lock mode.

2 Likes

:coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients:
I have experienced this issue in a funi korean ROBLOX game (3) Walk to school in OHIO - Roblox
anyways

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 :wink:
:coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients:

1 Like

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 MouseLockController ModuleScript 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 :coefficients: emoji was still available :hushed: It’s amazing :sunglasses:

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

to the PlayerModule

also what does P.S. mean? :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients:

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

1 Like

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

1 Like

The LocalScript has to be called PlayerScriptsLoader exactly and MUST have

_G.PlayerModule=require(script.Parent:WaitForChild("PlayerModule"))

When you want to disable ShiftLock You do

_G.PlayerModule:ToggleShiftLock(false,true,false)

NOT

_G.PlayerModule:ToggleShiftLock(false)

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 :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients:

I followed your instructions but the problem is still present. Thanks for trying to help :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients:

1 Like

did you even put PlayerModule [Toggle shiftlock] - Creator Store (roblox.com) in StarterPlayerScripts or put

function PlayerModule:ToggleShiftLock(enable, modifiedVar, modifier)
	self.cameras:ToggleShiftLock(enable, modifiedVar, modifier)
end

into the PlayerModule
make you did either of those :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients: :coefficients:
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

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.