PlayerModule Controller not enabling after death

Hey there. I’m currently using the player control module to enable and disable input. It works great, but once the player respawns, they can’t move at all anymore. I even tried manually enabling the module when they respawn, and still no response. Any ideas?

As context, here’s the code I used for the module:

local PlayerModule = require(plr.PlayerScripts.PlayerModule)
local controls = PlayerModule:GetControls()
		
if name == "Disable" then
	controls:Disable()
elseif name == "Enable" then
	controls:Enable()
end

This is in a remoteEvent function, if you’re wondering why there is a name variable.
Also, I know this is a terrible way of scripting this module, but I just can’t find a way to enable/disable the module without problems. (I even tried controls:Enable(false/true) )

1 Like

Dead and replaced, enable control if spawned one’s is disabled.

I’ve already tried manually enabling it.

I’ve actually had this problem recently, and I solved it.

It seems like you are disabling the controls at the start. You would need to create a variable to check if the player’s controls have already been disabled from the start.

local yourVariableName = false

if yourVariableName == false then
	controls:Disable()
	
	wait(6) --//Any number would be fine.
	
	yourVariableName = true
end

Now you have to use a CharacterAdded event.

player.CharacterAdded:Connect(function(character)
	if yourVariableName == true then
		controls:Disable()
		
		wait()
		
		controls:Enable(true)
	end
end)

Basically, you are just disabling then enabling their controls on death.

4 Likes

Wait, there is no explanation of “name” variable.

The OP stated it in the original post:

1 Like