Is there a reliable way to detect when a player resets character?

Title; I’m trying to detect, on server, when a player resets their character for a death message.

I’ve found literally nothing on this.

Try Humanoid.Died its an event that fires when the character has died

Doesn’t work for my use case. That fires for any kind of death

you can use a BindableEvent connected with a RemoteEvent to tell the server that the player reset, while this could be exploited you can probably do some fact checking

local StarterGui = game:GetService("StarterGui")

local player = game.Players.LocalPlayer

local ResetEvent = Instance.new("BindableEvent")
ResetEvent.Parent = script
ResetEvent.Event:Connect(function()
	-- this will fire when the player voluntarily resets

	local character = player.Character
	local humanoid: Humanoid = character:WaitForChild("Humanoid")
	if humanoid.Health == 0 then
		-- this will still trigger if the player is already dead so check before doing anything
		return
	end

	humanoid.Health = 0 -- you need to manually set the player's health since this is overwriting the reset button

	-- put what you want to do here
end)

task.spawn(function()
	local success
	repeat
		success = pcall(function() 
			StarterGui:SetCore("ResetButtonCallback", ResetEvent)
		end)
		task.wait(1)
	until success
end)

It doesnt? it always works for me. I guess it depends on your character system

@LuauOOP try @Inkthirsty post ive seen this before and it works most of the time

the BindableEvent fires every time the reset button is pressed which can include when the player is already dead so there should be a few extra checks such as adding a cooldown and making sure the player is alive. besides that i think thats the only way but im not sure

Well you would want to check the players health inside the function binded to the event to make sure they are absolutely dead

a little off topic but ive seen even while the reset button is disabled xbox or ps players can still reset so definitely abusable, especially in battlegrounds for example like The Strongest Battlegrounds ive seen many xbox players reset while in a move

Since you want server-side detection, something you could do is set a flag, on the server, for all other scenarios except the player resetting which you should be able to control (for example NPC logic, kill bricks, etc). That way if you detect the Humanoid.Died event on the server side, but the player doesn’t have the flag set (because the death wasn’t related to a script) you know that they did it themselves by resetting.

To avoid repetitive code, you can hide the setting of this flag inside an abstraction, for example a module function for damaging/killing the player.

Another interesting scenario that may need special handling is the player falling in the void, but this depends on your game behavior and what you want to happen in that case.

And allow me to explain why this works.

Create the bindable event (unless one already exists):

local StarterGui = game:GetService("StarterGui")

local player = game.Players.LocalPlayer

local ResetEvent = Instance.new("BindableEvent")

Then connect it to the event:

ResetEvent.Event:Connect(function()

And inside that function:

local character = player.Character
local humanoid: Humanoid = character:WaitForChild("Humanoid")
humanoid.Health = 0

Because when you override the ResetButtonCallback, Roblox stops automatically resetting the character, so you manually reset the character by settings its health to 0.

Now this bit here:

task.spawn(function()
	local success
	repeat
		success = pcall(function() 
			StarterGui:SetCore("ResetButtonCallback", ResetEvent)
		end)
		task.wait(1)
	until success
end)

Because Roblox’s CoreScripts (the built-in UI system) takes a moment to load.
This solves the “SetCore: ResetButtonCallback has not been registered by the CoreScripts” error by retrying every once per second and without crashing the script due to pcall() until CoreScripts are ready.

Great explanation and yes roblox does override this so you would definitely need to manually set the health to zero or just take damage on the humanoid by its maxhealth

2 options are avaiable in this kind of situation:

  • if there’s another damage source (sword, gun shoot) or sum, make sure to make a tag that tells who/what hit the player with its name on it, for a few seconds then dissapears, that way when you use Humanoid.HealthChanged, you can add a condition to tell if that was empty or not, and acts like the player resetted then the tag is empty

  • use UIS when the player presses keys and stuff but its way too complex, ask claude.ai instead :man_shrugging:

probably not a reliable method, but personally i would track the last damage source serverside

check this little snippet out

local Players = game:GetService("Players")
local latestDamage = {}
local timeout = 5

local function tagDamage(player)
    latestDamage[player] = os.clock()
end

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local humanoid = char:WaitForChild("Humanoid")
        humanoid.HealthChanged:Connect(function(newHealth)
            if newHealth < humanoid.MaxHealth then
                tagDamage(player)
            end
        end)
        humanoid.Died:Connect(function()
            local lastDamage = latestDamage[player]
            if lastDamage and os.clock() - lastDamage < timeout then
                print(player.Name.." died from damage")
            else
                print(player.Name.." probably reseted")
            end
        end)
    end)
end)

you can even add on to it, like making exceptions such as if the player has been hit by a weapon then died. but this is as far as i can go :face_exhaling:

I ended up just doing

humanoid:GetPropertyChangedSignal("Health"):Connect(function()
		if humanoid.Health <= 0 and not alreadyHandled then
			-- damage message logic stuff
		end
		DamageSystem.setDamageType(character, nil) -- set damage source to nil
	end)

but thanks i guess