Player Controls Module Fail to Sync After Respawn

im not sure if there was an engine update but recently ive been experiencing some sort of sync failure with the controls module when respawning. im aware that the module updates to new characters but it seems to have issues with states

for many years ive done something along the lines of this to toggle player controls from either server or client depending and its worked fine no problem until now. this script is in StarterCharacterScripts, i can put it in StarterPlayerScripts which fixes it but i first encountered this bug in a localscript in one of my other projects where i need to check to enable controls upon respawning due to actions that disable it. im aware this is a strange method that no one probably uses but its more reliable than anchoring humanoidrootpart or using DevComputerMovementMode/DevTouchMovementMode so im not complaining

local player = game.Players.LocalPlayer
local PlayerScripts = player.PlayerScripts

local controls = require(PlayerScripts:WaitForChild("PlayerModule")):GetControls()

local function busyPing(temp: boolean?)
	local busy = player:GetAttribute("busy")
	if busy == true or busy == nil then
		if temp then
			controls:Enable() -- temp until bug is fixed
		end
		controls:Disable()
	elseif busy == false then
		if temp then
			controls:Disable() -- temp until bug is fixed
		end
		controls:Enable()
	end
end

player:GetAttributeChangedSignal("busy"):Connect(busyPing)
busyPing(true)

an example of how this is an inconvenience is that i can disable controls but if im holding W it will make me keep moving forward and the only fix is to re-require the module. although i could easily just add a wait to require the module again and call busyPing again, thats not the point because theres no indicator that the module is broken anyway. here i get respawned and im holding W then I let go and im still moving although the controls module still points to my new humanoid

the only fix is to call the opposite then the state you want (since it doesnt try to update to the same state if it already thinks thats what the current state is) but the issue is that i never used to have to do this and ive been using this method since like 2023 so of course i noticed immediately when it broke

controls:Disable()
controls:Enable()

heres one of my projects where i need to handle controls in a script that resets upon respawning because actions like emoting or being in a menu disables controls and resetting would cause them to be softlocked without this. i temporarily removed my fix and i continue walking forward (if i wasnt holding w i wouldnt be able to move at all when respawning)

and the module is still the same and it updates to the new humaniod

print(controls == require(PlayerScripts:WaitForChild("PlayerModule")):GetControls())

RobloxStudioBeta_Y4ksp0K61P

sorry that i explained this poorly but tldr: control module fails to sync properly when its used in a script that restarts after respawning

Hi @Inkthirsty,

Thanks for the report! I am looking into the issue, could you provide more specific reproduction instructions / a place file for testing?

broken controls.rbxl (73.7 KB)
hope this helps

i will admit this is impractical but ive been using this method for years and it only broke very recently

edit: only fix i can find is to call the opposite function before calling the intended one, it seems like calling the same thing tries to avoid overwriting it but when this is done it seems to take the controls of the previous character if that makes sense

Hi @Inkthirsty,

Thanks for providing more details! I took a look and it seems the behavior is the StarterCharacterScripts’s EventHandler trying to call ControlModule’s Enable / Disable functions which bind and unbind actions with ContextActionService. When the respawn happens, the EventHandler script gets deleted and all associated contextual actions become invalid, so the handleMoveForward action handler doesn’t manage the Enum.UserInputState.End event when you release W.

ControlModule’s Enable/Disable isn’t an official API and we can’t guarantee that games will always be forwards compatible with new versions of PlayerScripts, so I am going to close this as not a bug by design. If you do want to implement this behavior, I have a couple of suggestions:

  • as you found out, call the opposite function before the intended one, which will unbind the action from the previously deleted script context and re-bind it to the active character’s script
  • instead of requiring the PlayerModule/ControlModule in StarterCharacterScripts and toggling it directly, fire a BindableEvent to a permanent controller script in StarterPlayerScripts that receives the event and calls the toggle
  • we also anticipate that future updates to PlayerScripts (such as IAS) may resolve this issue but cannot provide any timeline

thanks this is actually a better approach, i was thinking about using a script that doesnt reset on respawn but then i left for vacation so i didnt get to try it

ive used this for years and it only recently started acting up but thank you

edit: i reworked my system and it works how it did before thank you so much! i can walk forward upon respawning without having to repress W