Player Controls manipulation breaks character on spawn?

I’m using player controls to completely disable controls for certain things so they can’t move during an action for example. Everything works fine, I don’t use this anywhere else, no issues at all until I respawn. I made sure and checked that Controls:Disable() is only used in one spot within the script and that’s not called during player death or anything like that

local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()

However, when I respawn I’m completely stuck and can’t move. I even have this in the script but it doesn’t help

--//Fix Script On Player Death\\--
Player.CharacterAdded:Connect(function(Char)
	Character = Char
	
	--//Animations\\--
	Animations = RepStorage.Animations
	OpeAnims = {}
	Animator = Character:WaitForChild("Humanoid"):FindFirstChildOfClass("Animator")
	Functions.CreateAnimListFromFolder(Animator, OpeAnims, Animations.OpeAnims)
	
	--//Fix Character\\--
	Controls:Enable()
end)

This script is inside of a tool in StarterPack

2 Likes

Since PlayerModule is in PlayerScripts, that means that script will run even after death.

If the script is inside a tool, doesn’t that mean the Character has already spawned when the script is ran? Since tools are replicated to Backpack only after the character is spawned. You should check if the character already exists before connecting that CharacterAdded event.

I was experiencing this issue too. I found a solution to this by accident. If you do Controls:Disable() and then Controls:Enable() right after the character respawns, the character is able to move again.

--player spawns
local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
Controls:Disable()
Controls:Enable()
--your code 
7 Likes