Need help with debugging why when the player dies the minigame doesn't reset

So after I finished my minigame character I ran into a issue the Humanoid.Died event won’t fire

Code:

function reset() -- function to reset minigame
	There_is_a_playmate = false
	script:SetAttribute("Playingwithsomeone",false)
	MinigameProgress = 0
end

HitBox.Touched:Connect(function(Touched)
	local Player = game.Players:GetPlayerFromCharacter(Touched.Parent)
	if Player then
		local PlaytimeUI = Player.PlayerGui["NPC GUIS"].Playtime
		local Char = Player.Character or Player.CharacterAdded:Wait()
		local Humanoid = Char:WaitForChild("Humanoid")

		if not Char then warn("Character not found!") return end
		if not Humanoid then warn("Humanoid not found!") return end
		if script:GetAttribute("Playingwithsomeone") == true then return end
		
		script:SetAttribute("Playingwithsomeone",true)
		UpperTorso:FindFirstChild("Playtime ready go!"):Play()
		Humanoid.WalkSpeed = 0
		PlaytimeUI.Enabled = true
		PlaytimeUI.Progress.Text = "0/3"
		There_is_a_playmate = true
		rope(Player,Humanoid)
		Humanoid.Died:Connect(reset) -- To call function
	end
end)

Make sure the connection is made before they died. Earlier you handle that the better (you did it at the end of your touched event)

Also verify the character isn’t already dead at time of the connection

Add a Print to verify the part before the connection happens, check output for “Test”:

HitBox.Touched:Connect(function(Touched)
	local Player = game.Players:GetPlayerFromCharacter(Touched.Parent)
	if Player then
		local PlaytimeUI = Player.PlayerGui["NPC GUIS"].Playtime
		local Char = Player.Character or Player.CharacterAdded:Wait()
		local Humanoid = Char:WaitForChild("Humanoid")

		if not Char then warn("Character not found!") return end
		if not Humanoid then warn("Humanoid not found!") return end
		if script:GetAttribute("Playingwithsomeone") == true then return end
		
		script:SetAttribute("Playingwithsomeone",true)
		UpperTorso:FindFirstChild("Playtime ready go!"):Play()
		Humanoid.WalkSpeed = 0
		PlaytimeUI.Enabled = true
		PlaytimeUI.Progress.Text = "0/3"
		There_is_a_playmate = true
		rope(Player,Humanoid)
                print("Test")
		Humanoid.Died:Connect(reset) -- To call function
	end
end)

Thanks or the reply but I already solved the problem I’m very sorry if I wasted your time

If you don’t mind sharing what was the issue?