How can I make a player actually die with the Character Controller / Controller Manager?

So I’m currently working on redoing the movement system for my game with Character Controller / Controller Manager Character Controllers | Documentation - Roblox Creator Hub, the problem is, the player’s character straight up refuses to die.

I got the script setup from here: How to Actually Use Roblox's Physics Character Controllers

1 Like

You could always add a thread somewhere to handle the edge case for when a player dies and a controller is active.


local humanoid:Humanoid= character:FindFirstChildofClass("Humanoid") :: Humanoid
local controller:ControllerManager = character:FindFirstChildofClass("ControllerManager") :: ControllerManager

humanoid.Died:Once(function() 
        controller:Destroy()
end)

It’s strange because humanoid.Died doesn’t trigger

I looked this up, and some other users have had problems with the Died method calling sometimes, you could try changing it to this:

local healthConnection
healthConnection = humanoid:GetPropertyChangedSignal("Health"):Connect(function() 
	local health:number = humanoid.Health
	if health <= 0 then
		controller:Destroy()
		healthConnection:Disconnect() -- Now this works
	end
end)

This will trigger at any point the health goes at or below zero, and then disconnect automatically.

1 Like

Since you’re turning off the state machine when using character controller no states are automatically assigned / changed, meaning you’ll have to make your own state machine. Using other signals such as human.HealthChanged or :GetPropertyChangedSignal(“Health”) you can detect when the humanoids health is >= 0 and trigger the .Died signal, either by manually setting it’s state to dead or just firing a function.

1 Like

Thanks, it’s working now, I just transferred the controller:Destroy() to the server since the controller can only be accessed by the server

nvm it’s this one (My bad hehehehehe)

1 Like

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